How to Self-Host n8n on Your Own VPS with Docker (Beginner's Guide)

8 min read

Note: This isn’t a post from a DevOps wizard. I’m just a regular guy from the Netherlands who likes building things and saving a few bucks. I wanted to run n8n without paying for hosted versions, so I set it up myself — and honestly, it wasn’t that hard. If you’ve got the patience to tinker, you can do this too.

Table of Contents

  1. Why Self-Host n8n?
  2. What You’ll Need
  3. Step 1: Buy a VPS
  4. Step 2: SSH into Your VPS
  5. Step 3: Install Docker & Docker Compose
  6. Step 4: Set Up Your n8n Docker Compose File
  7. Step 5: Run n8n
  8. Step 6 (Optional): Point a Domain + Secure with HTTPS
  9. Step 7: Open Your Browser and Create Your First Workflow
  10. Troubleshooting Tips
  11. Wrap Up

Why Self-Host n8n?

  • 💸 Save money: The hosted version of n8n can get pricey. Hosting it yourself? Basically free, aside from the small cost of the VPS (mine costs ~€4/month).
  • 🔒 Full control: Your data stays with you.
  • 🔧 Tinker-friendly: Want to test a new automation? Go wild. It’s your playground.

What You’ll Need

  • A cheap VPS (I use Hetzner — cheap and reliable)
  • Basic terminal access (copy-paste level is fine)
  • A bit of patience
  • (Optional) A domain name if you want to access it via something like n8n.mydomain.com

Can I just use the IP address instead of a domain? Yes! You can skip the domain part and just access it via your VPS IP (e.g., http://65.108.xx.xx:5678). If you're fine with seeing “Not Secure” in the browser, that’s totally OK for testing and personal use.

Step 1: Buy a VPS

I went with Hetzner Cloud. Other options: DigitalOcean, Linode, etc.

  1. Create an account
  2. Choose the cheapest plan (e.g., 2vCPU, 2GB RAM is plenty for basic stuff)
  3. Select Ubuntu 22.04 as your OS

Once it's deployed, you’ll get an IP address. Save that.

Step 2: SSH into Your VPS

On your computer:

ssh root@YOUR_SERVER_IP

It’ll ask you to accept the fingerprint. Type yes and hit enter.

You’re now “inside” your server.

Step 3: Install Docker & Docker Compose

Install Docker:

apt update && apt install -y docker.io

Install Docker Compose:

apt install -y docker-compose

Check if it works:

docker --version
docker-compose --version

Step 4: Set Up Your n8n Docker Compose File

In your VPS, create a folder for n8n:

mkdir ~/n8n && cd ~/n8n

Create a file named docker-compose.yml:

nano docker-compose.yml

Paste this in:

version: '3.7'

services:
  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=yourpassword
    volumes:
      - ~/.n8n:/home/node/.n8n

Then:

docker-compose up -d

Boom. n8n is now running in a Docker container. Think of Docker as a little shipping container that runs a self-contained app.

Step 5: Run n8n

Now go to your browser:

http://YOUR_SERVER_IP:5678

Use the login details you set in docker-compose.yml.

Step 6 (Optional): Point a Domain + Secure with HTTPS

If you have a domain, you can point a subdomain (like n8n.yoursite.com) to your VPS IP.

Steps:

  1. Go to your domain DNS settings
  2. Add an A-record:
    • Name: n8n
    • Value: YOUR_SERVER_IP

Once that’s done, you can install nginx and certbot to handle HTTPS:

apt install -y nginx certbot python3-certbot-nginx

Then:

certbot --nginx -d n8n.yourdomain.com

Step 7: Open Your Browser and Create Your First Workflow

Go to your domain or IP:

https://n8n.yourdomain.com

or

http://YOUR_SERVER_IP:5678

Click “Create Workflow” and start automating. Try something simple: like sending yourself a daily email, or scraping a site.

Troubleshooting Tips

  • Can’t access the server? Check firewall settings or that your VPS allows port 5678.
  • Docker container restarting? Run docker logs CONTAINER_ID to see what’s wrong.
  • WebSocket error in browser? Try using Chrome instead of Safari.
  • Want to restart n8n? Run docker-compose restart

Wrap Up

Self-hosting n8n isn’t just a fun weekend project — it’s a super affordable way to get powerful automations without paying monthly fees.

I’m using it to:

  • Test automations
  • Build side projects
  • Explore ideas without limits

And it costs me less than a Spotify subscription.

If you found this helpful:

👉 Share it with someone else who’s into automation
👉 Follow me on X or check out markooms.com

Put This Into Practice

Ready to implement what you've learned? Check out our ready-to-use n8n workflows that complement this tutorial.

Browse n8n workflow library →