Flows On Demand — Workflow Automation Reviews
n
IntermediateInfrastructure · 60 min

How to Self-Host n8n: Complete Setup Guide

n8n is open-source, which means you can run it on your own server and get unlimited workflow executions for the price of a VPS (often $5–$10/month) instead of per-execution cloud pricing. This guide sets up a production-ready, HTTPS-secured n8n instance using Docker and Nginx. It assumes basic comfort with the command line.

By the FlowsOnDemand editorial team · Last updated May 2026

What you'll need

  • A VPS running Ubuntu 22.04 or later (DigitalOcean, Hetzner, Hostinger, etc.) — a $5–$6/mo plan is plenty to start
  • A domain or subdomain you can point at the server (e.g., n8n.yourdomain.com)
  • SSH access to the server and basic command-line familiarity
  • Docker and Docker Compose installed (covered in Step 1)

Why self-host?

  • Unlimited executionsno per-run charges, ever. A high-volume workflow that would cost $50+/mo on n8n Cloud runs for the flat cost of your VPS.
  • Full data privacyyour workflow data never leaves your server, which matters for regulated or sensitive data.
  • Trade-off: you own maintenanceupdates, backups, and uptime are your responsibility.

Step-by-step: deploy n8n with Docker + HTTPS

1

Point your domain at the server

In your DNS provider, create an A record for n8n.yourdomain.com pointing to your VPS's public IP address. DNS can take a few minutes to propagate — you can continue with setup while it does.

2

Install Docker and Docker Compose

SSH into your server and run: `curl -fsSL https://get.docker.com | sh` to install Docker. Docker Compose v2 ships as a plugin with modern Docker installs — confirm with `docker compose version`.

Tip

Run `docker --version` and `docker compose version` to confirm both installed before continuing.

3

Create a docker-compose file

Make a directory (`mkdir ~/n8n && cd ~/n8n`) and create a `docker-compose.yml` defining the n8n service. Set the environment variables N8N_HOST=n8n.yourdomain.com, N8N_PROTOCOL=https, WEBHOOK_URL=https://n8n.yourdomain.com/, and a volume (e.g., `~/n8n/data:/home/node/.n8n`) so your workflows persist across restarts.

Tip

Always mount a volume for /home/node/.n8n — without it, every workflow you build is lost when the container restarts.

4

Set basic auth credentials

In the same compose file, set N8N_BASIC_AUTH_ACTIVE=true, N8N_BASIC_AUTH_USER, and N8N_BASIC_AUTH_PASSWORD to lock the editor behind a login. Never expose an n8n instance to the internet without authentication.

5

Start the container

Run `docker compose up -d`. n8n starts on port 5678 inside the container. Check it's running with `docker compose logs -f` — you should see "n8n ready on ::, port 5678."

6

Install and configure Nginx as a reverse proxy

Install Nginx (`apt install nginx`), then create a server block for n8n.yourdomain.com that proxy_passes to http://127.0.0.1:5678. Include the WebSocket upgrade headers (proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";) — n8n's editor relies on WebSockets.

Tip

Missing the WebSocket upgrade headers is the #1 cause of a blank or constantly-reloading n8n editor behind Nginx.

7

Add HTTPS with Certbot

Install Certbot (`apt install certbot python3-certbot-nginx`) and run `certbot --nginx -d n8n.yourdomain.com`. Certbot fetches a free Let's Encrypt certificate and rewrites your Nginx config to serve HTTPS with auto-renewal.

8

Log in and build

Visit https://n8n.yourdomain.com, enter your basic-auth credentials, then create your n8n owner account. You now have a private, unlimited n8n instance. Build your first workflow with the "+" button.

Production hardening (do this before relying on it)

  • Back up the data volume regularlyyour workflows, credentials, and execution history live in /home/node/.n8n.
  • For more than a handful of workflows, switch the database from the default SQLite to PostgreSQL (set DB_TYPE=postgresdb and related env vars) for reliability.
  • Set a restart policy (restart: unless-stopped) in your compose file so n8n comes back after a server reboot.
  • Keep n8n updatedpull the latest image periodically with `docker compose pull && docker compose up -d`, and read release notes for breaking changes first.

Ready to build it?

n8n is the platform used in this guide.

Prefer no maintenance? Try n8n Cloud