How to Self-Host n8n and Access It from Anywhere
Dilum Darshana

Dilum Darshana @dilumdarshana

About: Full Stack Developer (Node.js, React.js and AWS) | Exploring Generative AI

Location:
Sri Lanka
Joined:
May 15, 2023

How to Self-Host n8n and Access It from Anywhere

Publish Date: Jul 28
0 0

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.

  1. Create a directory for n8n:
$ mkdir n8n-local && cd n8n-local
Enter fullscreen mode Exit fullscreen mode
  1. 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
Enter fullscreen mode Exit fullscreen mode
  1. Create .env file
GENERIC_TIMEZONE=Asia/Colombo
Enter fullscreen mode Exit fullscreen mode
  1. 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
Enter fullscreen mode Exit fullscreen mode
$ docker-compose up -d
Enter fullscreen mode Exit fullscreen mode
  1. Test from local

Open your browser and navigate to:

http://localhost:5678

Complete the registration and survey (if prompted), and you’ll land on the n8n dashboard:

n8n dashbaord

Setting up ngrok

Now let’s expose your local n8n instance to the internet using ngrok.

  1. Signup at ngrok
    https://dashboard.ngrok.com/signup

  2. Install ngrok
    Follow the instructions for your OS:

https://dashboard.ngrok.com/get-started/setup/macos

  1. Add auth token
$ ngrok config add-authtoken xxxxxx
Enter fullscreen mode Exit fullscreen mode

Your auth token can be found at: https://dashboard.ngrok.com/get-started/your-authtoken

  1. Start a tunnel to port 5678
ngrok http --url=xxxxx.ngrok-free.app 5678
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Start container again:

$ docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

That’s it! Visit:

https://xxxxx.ngrok-free.app

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...

Comments 0 total

    Add comment