serverserv serverserv

How to self-host n8n: step-by-step Docker setup with HTTPS

By Siam Ahmed, software engineer · 10 min read · Updated

To self-host n8n, rent a VPS with at least 1 vCPU and 4 GB of RAM, point a subdomain at it, install Docker, then run n8n behind a reverse proxy with Docker Compose so it gets HTTPS. It takes about 30 minutes. Self-hosted n8n Community Edition is free; you only pay for the server.

Can you self-host n8n for free?

Yes. n8n Community Edition is the free, self-hosted version of n8n. It has no cap on workflows or executions; your server's CPU and RAM set the practical limit. You pay only for the server it runs on.

Community Edition is published under n8n's Sustainable Use License, a fair-code licence rather than an open-source one. It lets you use n8n for your own internal business or personal purposes. Reselling access to n8n, or letting clients build workflows on your server, needs a commercial licence from n8n. Our n8n hosting page covers the licence questions in more detail.

Should you self-host n8n?

Self-hosting makes sense when the trade-offs below work in your favour.

Self-hosted n8nn8n Cloud
CostServer only, from about $5 a monthPaid plans with a monthly execution allowance
ExecutionsNot capped; limited by your serverCapped by plan
Where your data livesOn your own serverOn n8n's servers
Setup and updatesYou, or your hostn8n
Best forHigh volume, AI steps, private data, fixed budgetsTrying n8n, or teams with no one to run a server

The trade-off is upkeep: someone has to apply updates, take backups and keep the server secure. Our comparison of n8n Cloud vs self-hosted n8n and the n8n pricing guide go deeper on cost.

What you need before you start

  • A VPS. 1 vCPU and 4 GB RAM runs a small setup. Move to 8 GB or more for busy webhooks, large files or many AI steps. See n8n system requirements for sizing.
  • A Linux operating system. Ubuntu 24.04 or Debian 12 are the easiest choices.
  • A domain or subdomain, such as n8n.yourcompany.com. Webhooks and many app logins need a public HTTPS address.
  • SSH access to the server, ideally with an SSH key.

How to self-host n8n, step by step

This setup runs two containers: n8n, and Caddy as a reverse proxy that gets a free HTTPS certificate from Let's Encrypt automatically. n8n's own docs show the same idea with Traefik; Caddy needs less configuration.

  1. Point your subdomain at the server. In your DNS settings, create an A record for n8n (or your chosen name) with your server's public IPv4 address. Wait until it resolves before step 6, or the certificate request will fail.
  2. Log in and update the server.

    ssh root@your-server-ip

    apt update && apt upgrade -y

  3. Open the firewall for web traffic.

    ufw allow OpenSSH && ufw allow 80 && ufw allow 443 && ufw enable

  4. Install Docker and Docker Compose with Docker's official install script, then check both work.

    curl -fsSL https://get.docker.com | sh

    docker --version && docker compose version

  5. Create a project folder and an .env file.

    mkdir ~/n8n && cd ~/n8n

    Create .env with your own values. Generate the encryption key with openssl rand -hex 32 and store a copy somewhere safe: without it, saved credentials cannot be decrypted after a move or restore.

    DOMAIN=n8n.yourcompany.com
    GENERIC_TIMEZONE=America/Toronto
    N8N_ENCRYPTION_KEY=paste-your-generated-key-here
  6. Create the Caddyfile so Caddy serves n8n over HTTPS:
    {$DOMAIN} {
        reverse_proxy n8n:5678
    }
  7. Create compose.yaml:
    services:
      caddy:
        image: caddy:2
        restart: unless-stopped
        ports:
          - "80:80"
          - "443:443"
        environment:
          - DOMAIN=${DOMAIN}
        volumes:
          - ./Caddyfile:/etc/caddy/Caddyfile
          - caddy_data:/data
          - caddy_config:/config
    
      n8n:
        image: n8nio/n8n
        restart: unless-stopped
        environment:
          - N8N_HOST=${DOMAIN}
          - N8N_PORT=5678
          - N8N_PROTOCOL=https
          - NODE_ENV=production
          - N8N_WEBHOOK_URL=https://${DOMAIN}/
          - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
          - TZ=${GENERIC_TIMEZONE}
          - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY}
        volumes:
          - n8n_data:/home/node/.n8n
    
    volumes:
      caddy_data:
      caddy_config:
      n8n_data:

    n8n is not published on a public port; only Caddy is. On n8n versions before 2.30, use WEBHOOK_URL instead of N8N_WEBHOOK_URL.

  8. Start n8n.

    docker compose up -d

    Open https://n8n.yourcompany.com, create the owner account with a strong password, and build your first workflow. If the page does not load, run docker compose logs caddy to check the certificate request.

This setup uses SQLite, n8n's default database, stored in the n8n_data volume. It is fine for most small and medium setups. For heavy production use or queue mode with workers, add a PostgreSQL container and set n8n's DB_TYPE=postgresdb variables.

After the install: security, backups and updates

  • Lock down SSH. Use SSH keys and turn off password logins. Our guide to securing a self-hosted n8n server walks through 9 steps.
  • Back up the n8n_data volume and your .env file. Together they hold your workflows, credentials, execution history and encryption key. Exporting key workflows as JSON is an easy extra safety net.
  • Update regularly. Take a backup, read the release notes, then run docker compose pull && docker compose up -d. See how to update self-hosted n8n without losing workflows.
  • Keep the database small. Execution history grows over time. Check n8n's execution pruning settings so old runs are deleted and the disk does not fill up.

Skip the setup: n8n hosting with n8n installed

If you would rather not run the steps above, serverserv n8n hosting gives you your own KVM VPS with n8n Community Edition installed and set up, HTTPS included, and no cap on workflows or executions. You open n8n in your browser and start building; no Linux needed.

PlanServer3-year termMonthly
n8n Starter1 vCPU, 4 GB RAM, 50 GB NVMe$8.39/mo$13.39/mo
n8n Personal2 vCPU, 8 GB RAM, 100 GB NVMe$11.09/mo$18.79/mo
n8n Pro4 vCPU, 16 GB RAM, 200 GB NVMe$21.59/mo$44.09/mo
n8n Team8 vCPU, 24 GB RAM, 400 GB NVMe$30.99/mo$63.39/mo
n8n Enterprise16 vCPU, 32 GB RAM, 800 GB NVMe$61.39/mo$125.69/mo

Prices in USD. The intro price covers your first term; the plan then renews at the regular price shown on the plan. Your first order has a 14-day money-back guarantee.

Prefer to do it yourself on a plain server? Follow the steps above on a Linux VPS server with full root access.

Questions

Is self-hosted n8n free?

Yes. n8n Community Edition is free to self-host for your own business or personal use under n8n's Sustainable Use License. You pay only for the server, from about $5 a month.

How much RAM does self-hosted n8n need?

1 vCPU and 4 GB of RAM runs a small setup. Use 8 GB or more for busy webhooks, large files or many AI steps.

Can I self-host n8n without Docker?

Yes, with Node.js and npm, but Docker is the method n8n recommends for servers because it keeps updates and backups simple.

Can I self-host n8n on my own computer?

You can run n8n locally for testing, but workflows stop when the computer sleeps, and webhooks need a public address. A VPS keeps n8n online around the clock.

Does self-hosted n8n have execution limits?

No. Community Edition does not cap workflows or executions. Your server's CPU and RAM set the practical limit.

Can I move my workflows from n8n Cloud?

Yes. Export your workflows as JSON and import them on your self-hosted n8n. Saved credentials are encrypted per instance, so plan to re-enter them.

Should I choose n8n or OpenClaw?

n8n builds step-by-step workflows that connect your apps. OpenClaw runs AI agents that answer and act on their own. See OpenClaw vs n8n to compare.

Sources

Ready to deploy?

Pick a plan, choose a term and our team sets up your server for you.

See all plansTalk to sales

Need a custom server, bulk pricing or help moving from another host? Our team will build a quote for you.

Plans from $2.99/moSee plans