Skip to content

Self-hosting n8n with Docker: complete setup guide

This page may contain affiliate links.

If you've been anywhere near the UK side of the automation world lately, you've probably heard of n8n. It's a brilliant, open-source workflow automation tool that lets you connect hundreds of apps — Gmail, Slack, Notion, Stripe, you name it — without writing a single line of code. The catch? The cloud-hosted version charges per workflow execution, and that adds up fast. The fix? Self-host it on your own server. You get unlimited workflows, full control over your data, and you pay a flat fee for a VPS instead of a per-run tax. In this guide, I'll walk you through getting n8n running with Docker on a UK-friendly setup, from choosing a server to securing it properly.

Why self-host n8n at all?

Let's talk money first. The n8n cloud pricing model is usage-based — you pay for every workflow execution beyond a tiny free allowance. If you're building anything serious, like a lead-generation pipeline or an automated social media scheduler, you'll burn through those credits in a week. Self-hosting flips that entirely. You pay for a small VPS — typically around £5–£15 a month from providers like Hetzner, DigitalOcean, or a UK-based host like IONOS — and then run as many workflows as your server can handle. For a hobbyist or a small side hustle, that's a saving of hundreds of pounds a year.

There's also the data angle. When you self-host, your workflow data, API keys, and webhook payloads never leave your server. That matters if you're handling customer data or just prefer not to have your business logic sitting on someone else's infrastructure. And because n8n is open source, you're not at the mercy of a vendor changing their pricing or feature set overnight.

What you'll need before you start

Here's the shopping list. You don't need a monster machine — n8n is surprisingly light. A single-core VPS with 1GB of RAM will run it fine for personal use, though I'd recommend 2GB if you plan on running heavier workflows or multiple instances. You'll also need a domain name (or a subdomain) if you want HTTPS, which you absolutely do. A cheap .co.uk domain will set you back about £5 a year. Finally, you'll need a basic grasp of the command line — nothing scary, just SSH and a few Docker commands.

If you're on a budget and want to test locally first, you can run this on an old Raspberry Pi 4 or 5. It works surprisingly well. Just be aware that the SD card can wear out, so use a decent quality one — something like a Samsung EVO Select is a safe bet. But for a proper always-on setup, a VPS is the way to go.

Step-by-step: Docker installation and n8n setup

Once your server is up and running (Ubuntu 22.04 or 24.04 is a solid choice), SSH into it. First, update the package list and install Docker and Docker Compose:

sudo apt update && sudo apt upgrade -y
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER

Log out and back in so the group membership takes effect. Then create a directory for n8n and a docker-compose.yml file:

mkdir ~/n8n && cd ~/n8n
nano docker-compose.yml

Paste in the following configuration:

services:
  n8n:
    image: n8nio/n8n
    restart: unless-stopped
    ports:
      - '5678:5678'
    environment:
      - N8N_HOST=n8n.yourdomain.co.uk
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.yourdomain.co.uk/
      - GENERIC_TIMEZONE=Europe/London
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

Replace n8n.yourdomain.co.uk with your actual subdomain. Save and exit (Ctrl+X, then Y, then Enter). Now start it up:

docker compose up -d

Give it a minute to pull the image, then check it's running with docker ps. You should see the n8n container listed. If you visit your server's IP on port 5678, you'll see the n8n setup screen. But we're not done yet — we need HTTPS.

Reverse proxy with Caddy (the easy way to HTTPS)

You could fiddle with Nginx and certbot, but there's a far simpler route: Caddy. It automatically obtains and renews SSL certificates for you. Add a Caddy service to your docker-compose.yml:

  caddy:
    image: caddy:2
    restart: unless-stopped
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - caddy_data:/data
      - caddy_config:/config
    environment:
      - N8N_HOST=n8n.yourdomain.co.uk
      - N8N_PROTOCOL=https
    depends_on:
      - n8n

Then create a Caddyfile in the same directory:

n8n.yourdomain.co.uk {
    reverse_proxy n8n:5678
}

Restart everything with docker compose up -d and Caddy will grab a Let's Encrypt certificate for your subdomain automatically. Make sure your DNS A record points to your server's IP first, otherwise Caddy will fail the challenge. Once that's done, you'll have a fully secured n8n instance at https://n8n.yourdomain.co.uk.

Now, a quick word on backups. Your workflows live in the n8n_data volume. Set up a nightly cron job that copies that volume to a separate location, or use the built-in n8n export command. Trust me, losing months of workflow logic is not a fun way to spend a weekend. Something like docker exec n8n n8n export:workflow --backup --output=/backup run via cron will do the trick.

First workflow and practical tips

Once you're in the n8n editor, the fun begins. Start with something simple but genuinely useful — say, a workflow that watches your Gmail for invoices and saves attachments to a Google Drive folder. The n8n interface is drag-and-drop, and you'll find pre-built nodes for most popular services. One tip: use environment variables for any API keys rather than hardcoding them into workflows. It keeps your credentials out of the workflow JSON and makes it easier to move workflows between environments.

Another tip: enable the n8n queue mode if you plan on running many workflows concurrently. It uses Redis under the hood and scales much better than the default single-process mode. It's a bit more setup, but worth it if you're building anything that resembles a real product.

If you're feeling overwhelmed by the sheer number of nodes and options, don't worry — that's normal. The official n8n docs are excellent, and there are plenty of UK-based YouTubers covering real-world examples. But if you want to skip the trial-and-error phase entirely, I've put together a collection of n8n Starter Workflows — plug-and-play templates you can import in minutes, covering common use cases like lead capture, content scheduling, and invoice tracking. They're designed to work straight out of the box with your self-hosted instance, and they start from just £9. Think of it as a shortcut to the good stuff, not a replacement for learning the tool.

Wrapping up

Self-hosting n8n with Docker is one of the smartest moves you can make for your digital side hustle. You get unlimited automation power for the price of a couple of pints a month, you keep your data on your own server, and you learn a valuable skill along the way. The setup takes about an hour the first time, but once it's running, it just works. Start with a simple workflow, build from there, and before long you'll wonder how you ever lived without it. If you get stuck, the community is friendly and the docs are solid — and if you want a head start, those starter templates are waiting for you.

Happy automating, and may your workflows never fail silently.

Written by

Richard Tucker

View all posts →