Localhost Webhook

Hello. I am pretty new to n8n, so please no complicated replies :slight_smile:

Basically, when I try sending data to my webhook which starts with “localhost” (I am using Render via Docker), it just doesn’t work. I’ve seen that your URL should NOT start with localhost, but if not, how could I change that?

Thanks,
Malik

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @Malik_Mahjooba In your docker setup, you can specify an env variable like so:

- WEBHOOK_URL=https://yourdomain.com

You’ll probably have to restart your container once you’ve made that change.

Hey @Malik_Mahjooba Welcome to community.
Here is similar problem was discussed you can have a look
https://community.n8n.io/t/how-to-upload-doc-from-windows-system-to-docker-container-local-file/80820

Thanks, but how can I do so?
I am pretty new to this Automation stuff, I’ve been with Make.com for a while however.

Thank you!
I am on Mac, and it doesn’t look like the solution.

Check this video on how to define the env var in render https://youtu.be/bb5Q2D8Jhtg?feature=shared

1 Like

You can use free service like duckdns.org to obtain free domain name.

Set Up Nginx Proxy Manager (NPM)

Create a directory for NPM:

mkdir ~/npm && cd ~/npm nano docker-compose.yml

version: '3' 
services: app: image: 'jc21/nginx-proxy-manager:latest' 
    restart: unless-stopped ports: 
    - '80:80' 
    - '443:443'  
    - '81:81' 
    - volumes: 
      - ./data:/data 
      - ./letsencrypt:/etc/letsencrypt

Start NPM:

docker-compose up -d


4. Configure DNS

  1. Log in to your domain registrar’s dashboard.
  2. Create an A record pointing your domain (e.g., n8n.your-domain.com) to your server’s public IP.

5. Configure NPM Proxy Host

  1. Access NPM’s admin panel at http://<your-server-ip>:81.
  1. Add Proxy Host:
  • Domain Names: n8n.your-domain.com
  • Forward Hostname/IP: Your server’s local IP (e.g., 192.168.1.100).
  • Forward Port: 5678 (n8n’s port).
  1. SSL Tab:
  • Request a new Let’s Encrypt certificate.
  • Enable Force SSL and HTTP/2.

6. Secure n8n (Optional but Recommended)

  • Change NPM’s default admin credentials.
  • Use a stronger authentication method (e.g., OAuth) for n8n instead of basic auth.

7. Verify Access

Visit https://n8n.your-domain.com in your browser. You should:

  1. See the n8n login page.
  2. Get a valid SSL padlock (:lock:).
  3. Log in using the basic auth credentials from Step 2.

8. Maintenance & Backups

  • Update Containers:

docker-compose pull && docker-compose up -d --force-recreate

  • Backup:
    • NPM: Backup the ~/npm/data and ~/npm/letsencrypt folders.

Troubleshooting

  • SSL Issues: Ensure ports 80/443 are open and DNS A record is correct.
  • DNS Errors: Wait for propagation (up to 48 hours) or use dig n8n.your-domain.com.

Or watch this video on youtube:
HomeLab SSL certificates for FREE with minimal effort

1 Like

Thank you!

Should it be easier to setup self-hosting w/ DigitalOcean or Railway than Render?

I think that setting up self-hosted n8n on DigitalOcean , Railway , or Render is similar in complexity , but the choice ultimately depends on the features and use cases that best align with your needs.

Hello guys. I am facing a similar issue but with a different architecture.
I am running n8n in queue mode using docker and several machines/hosts.

For that, i want my main instance to be deployed on machine1
here is the docker command i used to run it:

docker run -d --name n8n-main --env-file /data/apps/dockerrepo/N8N/n8nenvfile.env -e N8N_HOST=machine1 -e WEBHOOK_URL="http://machine2:5678" -e N8N_DISABLE_PRODUCTION_MAIN_PROCESS=true -p 5678:5678 2edaf374e990

Then i want my webhook instance to run on machine 2, and here is the docker command i have used to run:

docker run -d --name n8n-webhook --env-file /data/apps/dockerrepo/N8N/n8nenvfile.env -e N8N_HOST=machine2 -p 5678:5678 2edaf374e990 webhook

and 2 workers running on 2 separate machines.

The problem is that the docker command of the webhook is not starting. when i run the command, the contain goes up for 2 seconds and then dies, with no logs when i run: docker logs [container-id]

To note that the 3 instances (main, webhook, workers) share the same env file that is deployed on the different machines.
and no connectivity issues.

n8n docker image the same (v1.80.0)

Should the WEBHOOK_URL env variable be only https ?
Am i missing any config (knowing that Redis and Postgresdb are well connected)

It should be reachable from outside your local network so it is recommended to connect to your instance Fully Qualified Domain Names (FQDNs). Look above it doesn’t matter which architecture you use, your http://machine2:5678 isn’t reachable from outside your network or networks.

1 Like

yes all machines are accessible from our internal network, and i don’t have the intention to expose the service to outside of our network. it’s only for internal use.
my main issue is that the docker container with “webhook” configuration is not starting.

another concern was "where should i specify the WEBHOOK_URL env variable ? in the main container ? or in the webhook container? "

Please read this docs: https://docs.n8n.io/hosting/scaling/queue-mode/#running-n8n-with-queues

@Ruslan_Yanyshyn this was exactly the document i was following.
but trust me it wasn’t clear :smiley: about this issue that i was facing.

seems the command “webhook” in the docker image is not launching the instance with webhook config.

Here is my docker compose file:

volumes:
  db_storage:
  n8n_storage:
  redis_storage:

x-shared: &shared
  restart: always
  image: docker.n8n.io/n8nio/n8n
  environment:
    - DB_TYPE=postgresdb
    - DB_POSTGRESDB_HOST=postgres
    - DB_POSTGRESDB_PORT=5432
    - DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
    - DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
    - DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
    - EXECUTIONS_MODE=queue
    - QUEUE_BULL_REDIS_HOST=redis
    - QUEUE_HEALTH_CHECK_ACTIVE=true
    - NODE_ENV=production
    - WEBHOOK_URL=https://n8n.example.com
    - NODE_FUNCTION_ALLOW_EXTERNAL=*
    - N8N_LOG_LEVEL=debug
    - N8N_LOG_OUTPUT=file
    - N8N_LOG_FILE_LOCATION=/home/node/n8nlogs/n8n.log
    - N8N_LOG_FILE_MAXSIZE=50
    - N8N_LOG_FILE_MAXCOUNT=60
    - N8N_ENCRYPTION_KEY=example_key:)
    - GENERIC_TIMEZONE=America/Edmonton
  links:
    - postgres
    - redis
  volumes:
    - n8n_storage:/home/node/.n8n
  depends_on:
    redis:
      condition: service_healthy
    postgres:
      condition: service_healthy

services:
  postgres:
    image: postgres:16
    container_name: n8n-postgres
    restart: always
    environment:
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_DB
      - POSTGRES_NON_ROOT_USER
      - POSTGRES_NON_ROOT_PASSWORD
    volumes:
      - db_storage:/var/lib/postgresql/data
      - ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
    healthcheck:
      test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
      interval: 5s
      timeout: 5s
      retries: 10

  redis:
    image: redis:7-alpine
    container_name: n8n-redis
    restart: always
    volumes:
      - redis_storage:/data
    healthcheck:
      test: ['CMD', 'redis-cli', 'ping']
      interval: 5s
      timeout: 5s
      retries: 10

  n8n:
    <<: *shared
    container_name: n8n
    ports:
      - 5678:5678

  n8n-worker-1:
    <<: *shared
    container_name: n8n-worker-1
    command: worker
    depends_on:
      - n8n

  n8n-worker-2:
    <<: *shared
    container_name: n8n-worker-2
    command: worker
    depends_on:
      - n8n

  n8n-worker-3:
    <<: *shared
    container_name: n8n-worker-3
    command: worker
    depends_on:
      - n8n    

  n8n-worker-4:
    <<: *shared
    container_name: n8n-worker-4
    command: worker
    depends_on:
      - n8n   

  n8n-worker-5:
    <<: *shared
    container_name: n8n-worker-5
    command: worker
    depends_on:
      - n8n    

hi @Ruslan_Yanyshyn thanks for the updates

in the shared docker compose, i don’t see that you launched a separate webhook instance using the command “webhook”, and that is needed for scaling the webhook instance while keeping the main instance running separately

i would have expected something like this:

  n8n:
    <<: *shared
    container_name: n8n
    ports:
      - 5678:5678

  n8n-worker-1:
    <<: *shared
    container_name: n8n-worker-1
    command: worker
    depends_on:
      - n8n

  n8n-webhook-1:
    <<: *shared
    container_name: n8n-worker-1
    command: webhook
    depends_on:
      - n8n

Yes, you’re right—it should be something like this. I haven’t tried it myself yet. For my use case, I’m good with the main n8n container for this role.

 n8n:
    <<: *shared
    container_name: n8n
    ports:
      - 5678:5678

  n8n-worker-1:
    # ... unchanged ...

 

  n8n-webhook:
    <<: *shared
    container_name: n8n-webhook
    command: webhook
    ports:
      - 5679:5678

exactly.
and for this config, when trying to run it on a separate machine, the webhook container is not starting at all. (n8n version is 1.80.0)

@Ruslan_Yanyshyn do you have any idea why the webhook container is not starting ?