Deploy n8n Locally & Make It Public Using Cloudflare Tunnel | Free Forever
Table of Contents
Introduction
In this tutorial, you'll learn how to deploy n8n locally using Docker and securely expose it to the internet using a Cloudflare Tunnel. This setup allows you to automate workflows with n8n while ensuring your instance remains accessible from anywhere, all for free. By the end of this guide, you'll have a functional n8n setup accessible via a public domain.
Step 1: Install Docker
To get started, you need Docker installed on your local machine. Follow these steps:
-
Download Docker:
- Go to the Docker website.
- Choose the version compatible with your operating system (Windows, macOS, Linux).
-
Install Docker:
- Follow the installation instructions specific to your OS.
- Ensure Docker is running by executing
docker --versionin your terminal.
Step 2: Deploy n8n Using Docker
Now that Docker is set up, you can deploy n8n.
-
Open Terminal.
-
Run the n8n Docker command: Use the following command to pull the n8n image and run it:
docker run -d --name n8n -p 5678:5678 n8nio/n8n- This command runs n8n in detached mode (
-d) and maps port 5678 on your local machine to port 5678 in the container.
- This command runs n8n in detached mode (
-
Access n8n:
- Open your web browser and navigate to
http://localhost:5678. - You should see the n8n interface.
- Open your web browser and navigate to
Step 3: Create a Cloudflare Account
To make your local n8n instance publicly accessible, you need a Cloudflare account.
-
Sign up for Cloudflare:
- Visit the Cloudflare website.
- Create an account if you don’t already have one.
-
Add your domain:
- Follow the prompts to add your domain to Cloudflare.
- Make sure your domain's DNS settings are correctly configured.
Step 4: Set Up Cloudflare Tunnel
Next, you’ll create a tunnel to expose your local n8n instance.
-
Install Cloudflare Tunnel:
- Follow the Cloudflare Tunnel documentation to install the necessary software.
-
Authenticate the Tunnel:
- Run the authentication command:
cloudflared login- This will open a browser window where you can log in to your Cloudflare account.
-
Create a Tunnel:
- Use the following command to create a new tunnel:
cloudflared tunnel create n8n-tunnel -
Configure the Tunnel:
- Create a configuration file (e.g.,
config.yml) with the following content:
tunnel: YOUR_TUNNEL_ID credentials-file: /path/to/YOUR_TUNNEL_ID.json ingress: - hostname: YOUR_PUBLIC_DOMAIN service: http://localhost:5678 - service: http_status:404 - Create a configuration file (e.g.,
-
Run the Tunnel:
- Start the tunnel using the command:
cloudflared tunnel run n8n-tunnel
Step 5: Access Your n8n Instance Publicly
With the tunnel running, you can now access your n8n instance via your public domain.
- Open Your Browser.
- Navigate to Your Public Domain:
- Enter
http://YOUR_PUBLIC_DOMAINin the address bar. - You should see the n8n interface accessible from the internet.
- Enter
Conclusion
Congratulations! You have successfully deployed n8n locally using Docker and exposed it securely to the internet with Cloudflare Tunnel. This setup allows you to leverage the powerful automation capabilities of n8n while ensuring accessibility from anywhere.
Next Steps
- Explore n8n's features by creating workflows.
- Consider adding more security measures, such as authentication methods.
- Keep your Docker and Cloudflare Tunnel updated for optimal performance and security.