Hello devs,
If you are building workflows and automations using n8n, you have probably thought:
“Can I run this on my own server and access it from anywhere?”
The answer is yes — and in this guide, I'll show you how to self-host n8n with Docker, securely expose it using ngrok, and run your automations from anywhere in the world.
Installing and Running n8n Locally
Running n8n with Docker is the easiest and most consistent way to set it up locally. It keeps your environment isolated, reproducible, and production-ready. No need to worry about system dependencies.
- Create a directory for n8n:
$ mkdir n8n-local && cd n8n-local
- Create a docker-compose.yml file:
services:
n8n:
image: docker.n8n.io/n8nio/n8n
container_name: my-n8n-workflow
restart: always
ports:
- "5678:5678"
environment:
# - DOMAIN_NAME=example.com
# - SUBDOMAIN=n8n
# - N8N_HOST=n8n.example.com
# - N8N_PROTOCOL=https
# - N8N_PORT=5678
# - NODE_ENV=production
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
- N8N_SECURE_COOKIE=false
# - N8N_EDITOR_BASE_URL=<ngrok url>
- N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true
# - WEBHOOK_URL=<ngrok url>
- N8N_DEFAULT_BINARY_DATA_MODE=filesystem
volumes:
- ./n8n_data:/home/node/.n8n
- Create .env file
GENERIC_TIMEZONE=Asia/Colombo
- Start container
Note: There can be a user ownership issue in the n8n_data folder. Run the following command from the folder where container running,
$ sudo chown -R 1000:1000 ./n8n_data
$ docker-compose up -d
- Test from local
Open your browser and navigate to:
Complete the registration and survey (if prompted), and you’ll land on the n8n dashboard:
Setting up ngrok
Now let’s expose your local n8n instance to the internet using ngrok.
Signup at ngrok
https://dashboard.ngrok.com/signupInstall ngrok
Follow the instructions for your OS:
https://dashboard.ngrok.com/get-started/setup/macos
- Add auth token
$ ngrok config add-authtoken xxxxxx
Your auth token can be found at: https://dashboard.ngrok.com/get-started/your-authtoken
- Start a tunnel to port 5678
ngrok http --url=xxxxx.ngrok-free.app 5678
ngrok will provide a public HTTPS domain like https://xxxxx.ngrok-free.app.
Binding everything together
Now it’s time to update your Docker setup with the ngrok URL.
We need to stop the existing docker container, if it is running,
$ docker-compose down
Replace the environment variables with the ngrok domain:
services:
n8n:
image: docker.n8n.io/n8nio/n8n
container_name: my-n8n-workflow
restart: always
ports:
- "5678:5678"
environment:
# - DOMAIN_NAME=example.com
# - SUBDOMAIN=n8n
# - N8N_HOST=n8n.example.com
# - N8N_PROTOCOL=https
# - NODE_ENV=production
- N8N_PORT=5678
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
- N8N_SECURE_COOKIE=false
- N8N_EDITOR_BASE_URL=xxxxx.ngrok-free.app
- N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true
- WEBHOOK_URL=xxxxx.ngrok-free.app
- N8N_DEFAULT_BINARY_DATA_MODE=filesystem
volumes:
- ./n8n_data:/home/node/.n8n
Start container again:
$ docker-compose up -d
That’s it! Visit:
You now have full access to your local n8n instance from anywhere in the world.
Conclusion
Self-hosting n8n with Docker and exposing it using ngrok is a powerful way to:
- Rapidly test webhooks and integrations
- Run automations privately and securely
- Avoid deploying to cloud platforms for quick experiments
This setup gives you the flexibility to develop and demo from anywhere — perfect for both learning and production prototypes. You can always enhance it later with a custom domain, HTTPS via Let's Encrypt, or move to a VPS if needed.
If you're exploring automation workflows or integrating n8n into your stack, give this setup a try — and let me know how it goes!
Cheers...