Skip to Content

Deploy n8n

Fair-code workflow automation tool. Easily automate tasks across different services.

⭐ 49.0k stars📜 Sustainable Use License🔴 Advanced⏱ ~20 minutes

What You’ll Get

A fully working n8n instance running on your server. Your data stays on your hardware — no third-party access, no usage limits, no surprise invoices.

Prerequisites

  • A server with Docker and Docker Compose installed (setup guide)
  • A domain name pointed to your server (optional but recommended)
  • Basic terminal access (SSH)

The Config

Create a directory for n8n and add this docker-compose.yml:

# ------------------------------------------------------------------------- # 🚀 Created and distributed by The AltStack # 🌍 https://thealtstack.com # ------------------------------------------------------------------------- version: '3.8' services: n8n: image: n8nio/n8n:latest container_name: n8n restart: unless-stopped ports: - "5678:5678" environment: - N8N_BASIC_AUTH_ACTIVE=true - N8N_BASIC_AUTH_USER=admin - N8N_BASIC_AUTH_PASSWORD=password - N8N_HOST=localhost - N8N_PORT=5678 - N8N_PROTOCOL=http - NODE_ENV=production - WEBHOOK_URL=http://localhost:5678/ volumes: - n8n_data:/home/node/.n8n volumes: n8n_data:

Let’s Ship It

# Create a directory mkdir -p /opt/n8n && cd /opt/n8n # Create the docker-compose.yml (paste the config above) nano docker-compose.yml # Pull images and start docker compose up -d # Watch the logs docker compose logs -f

Environment Variables

VariableDefaultRequired
N8N_BASIC_AUTH_ACTIVEtrueNo
N8N_BASIC_AUTH_USERadminNo
N8N_BASIC_AUTH_PASSWORDpasswordNo
N8N_HOSTlocalhostNo
N8N_PORT5678No
N8N_PROTOCOLhttpNo
NODE_ENVproductionNo
WEBHOOK_URLhttp://localhost:5678/No

Post-Deployment Checklist

  • Service is accessible on the configured port
  • Admin account created (if applicable)
  • Reverse proxy configured (Caddy guide)
  • SSL/HTTPS working
  • Backup script set up (backup guide)
  • Uptime monitor added (Uptime Kuma)

The “I Broke It” Section

Container won’t start?

docker compose logs n8n | tail -50

Port already in use?

# Find what's using the port lsof -i :PORT_NUMBER

Need to start fresh?

docker compose down -v # ⚠️ This deletes volumes/data! docker compose up -d

Going Further