n8n Logo

Install n8n with Docker

n8n is a powerful open-source workflow automation tool — a self-hosted alternative to Zapier or Make. Connect applications and services into complex automations that stay fully under your control.

Prerequisites:
✓ A server running a recent Linux distribution (e.g. Ubuntu 22.04)
Docker and Docker Compose installed on the server
✓ A domain name pointing to your server's IP address (required for production use)

Step 1: Create the Project Directory and Files

Log in to your server via SSH and create a directory for n8n. Inside it, create the Compose file and a .env file for your configuration variables:

Create Directory and Files
mkdir n8n && cd n8n && touch docker-compose.yml .env && nano docker-compose.yml

Paste the following content into the docker-compose.yml file:

docker-compose.yml
version: '3' services: n8n: image: n8nio/n8n restart: always ports: - '127.0.0.1:5678:5678' environment: - N8N_HOST=${N8N_HOST} - N8N_PORT=5678 - N8N_PROTOCOL=https - NODE_ENV=production - WEBHOOK_URL=${WEBHOOK_URL} - GENERIC_TIMEZONE=${GENERIC_TIMEZONE} volumes: - ./n8n_data:/home/node/.n8n

Binding to 127.0.0.1:5678 ensures n8n is only accessible locally for security reasons. External access is handled by the reverse proxy in Step 4.

Step 2: Configure Environment Variables

Open the .env file with nano .env and paste the following content. Adjust the values to match your setup:

.env
# Timezone for workflow scheduling GENERIC_TIMEZONE=Europe/Berlin # Public URL of your n8n instance (required for webhooks) WEBHOOK_URL=https://n8n.yourdomain.com # Hostname for n8n N8N_HOST=n8n.yourdomain.com

WEBHOOK_URL is critical: This variable must be set to the final, public URL of your n8n instance — otherwise webhooks will not function correctly. When using HTTPS, it must start with https://.

Step 3: Start n8n

Start the n8n container with the following command. Docker will pull the image and start the container in the background.

Start Docker Compose
docker compose up -d

Step 4: Set Up a Reverse Proxy (Required)

Since n8n is only accessible locally by default (127.0.0.1:5678), you must set up a reverse proxy to access it from the internet via your domain. The reverse proxy forwards requests from your public domain (e.g. https://n8n.yourdomain.com) to the local n8n container and handles HTTPS termination.

Common tools for this are Nginx Proxy Manager, Traefik, or Caddy. All three can run as Docker containers and integrate well with this setup.

Step 5: First Access and Account Setup

Once your reverse proxy is configured, open your browser and navigate to your n8n domain (e.g. https://n8n.yourdomain.com).

On first load, you will be prompted to create an owner account — enter an email address and a secure password. This will be your main administrator account for n8n.

Further Documentation

For advanced configuration, workflow templates, and integration guides, refer to the official n8n documentation.