Install n8n on Hetzner Cloud with public IP addres instead of domain

Hey, I’m a newbie in n8n. Today I spent 4 hours installing n8n docker on the Hetzner Cloud server. I followed the guide here https://docs.n8n.io/hosting/installation/server-setups/hetzner/

I tried to set it with the IP address, not the domain name. So, basically, the goal is to put http://ip_address in the browser and get to the n8n web panel.

I tried many times, but I need help. Maybe someone would be so nice as to check the config files below and tell me what I’m doing wrong.

.env

# Replace <directory-path> with the path where you created folders earlier
#DATA_FOLDER=/<directory-path>/n8n-docker-caddy
DATA_FOLDER=/root/n8n-docker-caddy


# The top level domain to serve from, this should be the same as the subdomain you created above
#DOMAIN_NAME=example.com
DOMAIN_NAME=116.203.21.64

# The subdomain to serve from
#SUBDOMAIN=n8n
SUBDOMAIN=

# DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from
# above example would result in: https://n8n.example.com

# Optional timezone to set which gets used by Cron-Node by default
# If not set New York time will be used
GENERIC_TIMEZONE=Europe/Berlin

# The email address to use for the SSL certificate creation
[email protected]

Caddyfile

:80 {
        reverse_proxy 127.0.0.1:5678
}

116.203.21.64:80 {
        reverse_proxy 127.0.0.1:5678
}

docker-compose.yml

services:
  caddy:
    image: caddy:latest
    restart: unless-stopped
    ports:
      - "80:80"
    volumes:
      - caddy_data:/data
      - ${DATA_FOLDER}/caddy_config:/config
      - ${DATA_FOLDER}/caddy_config/Caddyfile:/etc/caddy/Caddyfile

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - 5678:5678
    environment:
      - N8N_HOST=${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - NODE_ENV=production
      - WEBHOOK_URL=http://${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - n8n_data:/home/node/.n8n
      - ${DATA_FOLDER}/local_files:/files

volumes:
  caddy_data:
    external: true
  n8n_data:
    external: true

Information on your n8n setup

  • n8n version: 1.68.0
  • Running n8n via (Docker, npm, n8n cloud, desktop app): DOCKER

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:

Hello,
Could you give a little bit more information on what kind of error you’re facing when trying to connect to the server. Is it a timeout ? Is it a 404 page ? Or any other error ?

Thank you for your interest. Today I finally make it work. I generated self-signed certificate and decided to go with https://. Important thing is to put in Caddyfile in reverse_proxy the container name not the IP address or localhost.

Below my files if anyone have similar problem:

.env

# Directory path for n8n data
DATA_FOLDER=/root/n8n-docker-caddy

# Use the server's public IP address
DOMAIN_NAME=116.203.21.65
SUBDOMAIN=

# Timezone configuration
GENERIC_TIMEZONE=Europe/Berlin

# Email address for SSL certificate creation (not used in this setup)
[email protected]

Caddyfile

:443 {
    reverse_proxy n8n-docker-caddy-n8n-1:5678
    tls /config/selfsigned.crt /config/selfsigned.key
}

docker-compose.yml

services:
  caddy:
    image: caddy:latest
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - caddy_data:/data
      - ${DATA_FOLDER}/caddy_config:/config
      - ${DATA_FOLDER}/caddy_config/Caddyfile:/etc/caddy/Caddyfile

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - 5678:5678
    environment:
      - N8N_HOST=${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=http://${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - n8n_data:/home/node/.n8n
      - ${DATA_FOLDER}/local_files:/files

volumes:
  caddy_data:
    external: true
  n8n_data:
    external: true

Hello again,

Glad you managed to make it work!
Indeed 127.0.0.1 doesn’t work because n8n and caddy are in different containers, they can’t communicate over localhost because docker isolates their network.
Though, docker should also make the n8n service available and this Caddy config should also work:

:443 {
    reverse_proxy n8n:5678
    tls /config/selfsigned.crt /config/selfsigned.key
}
1 Like