
Self-hosting n8n on an Ubuntu Server
Jonas ScholzWant to automate tasks using n8n but prefer to fully control your infrastructure? By self-hosting n8n on an Ubuntu server, you can own your data, avoid per-workflow hosting surprises, and run automation workflows on infrastructure you control.
This guide shows the DIY path with Docker Compose and Caddy. If you would rather skip server management and deploy n8n in about a minute, use the Sliplane n8n preset or read self-hosting n8n the easy way.
Quick Answer
You can self-host n8n on Ubuntu with Docker Compose and Caddy, but you will own server security, HTTPS, backups, updates, monitoring, and recovery.
Use Sliplane if you want to run your own n8n container with persistent storage, HTTPS, logs, health checks, and backups without maintaining Ubuntu manually.
DIY vs Sliplane
| Route | Cost | Setup time | Maintenance | Best for |
|---|---|---|---|---|
| Raw VPS | €4-€15/month | 1-3 hours | High | Developers who want full server control |
| Sliplane | From €9/month | Minutes | Low | Builders who want managed self-hosting |
| n8n Cloud | From €20/month billed annually | Minutes | Low | Teams that prefer official SaaS |
Follow along this easy-to-understand guide to learn how you can deploy your own n8n instance using Docker and Caddy Web server for automatic HTTPS.
Before we start, make sure you have:
- a running Ubuntu Linux server instance. A good option is Hetzner, but any Ubuntu server that you can login to with SSH and that has a public IP address works.
- a domain or subdomain pointing to that server if you want HTTPS and production webhooks.
- basic SSH experience.
What You Will Build
By the end, you will have:
- n8n running in Docker Compose
- persistent n8n data stored in a Docker volume
- Caddy reverse proxying traffic to n8n
- HTTPS through Caddy and Let's Encrypt
- a firewall that exposes only SSH, HTTP, and HTTPS
- a repeatable update command for future n8n releases
Step 1: Update Your Server
Log into your Ubuntu server via SSH and update the system to ensure it has the latest security patches and updates.
sudo apt-get update
sudo apt-get upgrade -y
Once finished, your server is ready for installing the software.
Step 2: Install and Configure UFW Firewall
Only keep necessary ports open: SSH (22), HTTP (80), HTTPS (443).
Install UFW and configure the firewall as follows:
sudo apt install ufw -y
sudo ufw allow 22 # SSH
sudo ufw allow 80 # HTTP
sudo ufw allow 443 # HTTPS
sudo ufw enable
Check your firewall configuration:
sudo ufw status verbose
Note: Docker can sometimes ignore UFW rules. To tackle this, verify extra settings as explained here.
Step 3: Docker Installation
Docker will be the container system running n8n. Install Docker by running these commands:
Setup dependencies and Docker's GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Add Docker repository:
echo \
"deb [arch=$(dpkg --print-architecture) \
signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo $VERSION_CODENAME) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Install Docker Engine and compose-plugin:
sudo apt-get install docker-ce docker-ce-cli \
containerd.io docker-buildx-plugin docker-compose-plugin -y
Check installation:
sudo docker run hello-world
If you see the "hello-world" message, Docker is ready.
Step 4: Installing Caddy for Automatic HTTPS
Caddy simplifies HTTPS configuration since it handles SSL certificates automatically from Let's Encrypt.
Install Caddy:
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
| sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
| sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy -y
Edit the Caddyfile configuration file:
sudo nano /etc/caddy/Caddyfile
Enter your domain and configure reverse proxy. Replace "yourdomain.com" with your actual domain name:
yourdomain.com {
reverse_proxy localhost:5678
}
If no domain yet, use this temporarily:
:80 {
reverse_proxy localhost:5678
}
Restart Caddy to load the config:
sudo systemctl restart caddy
Step 5: Running n8n with Docker Compose
We're going to use Docker Compose for easier setup. First create a directory for n8n and navigate to it:
mkdir ~/n8n
cd ~/n8n
Create docker-compose.yml with the following content:
services:
n8n:
image: docker.io/n8nio/n8n:2.29.10
restart: always
ports:
- "127.0.0.1:5678:5678"
environment:
- N8N_HOST=yourdomain.com
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://yourdomain.com/
- N8N_ENCRYPTION_KEY=replace-with-a-long-random-secret
- GENERIC_TIMEZONE=Europe/Berlin
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
Replace yourdomain.com with your real domain. Also replace N8N_ENCRYPTION_KEY with a long random value and keep it safe. n8n uses it to encrypt credentials, so changing it later can make existing credentials unusable. n8nio/n8n:2.29.10 was the current stable image when this guide was refreshed in 2026; before production updates, check the n8n Docker tags and pin an exact version after testing.
Now deploy n8n by running Docker Compose:
sudo docker compose up -d
Docker pulls the n8n image and runs it in background mode using port 5678.
Step 6: Accessing Your Self-Hosted n8n Instance
Visit your domain in any web browser. Your n8n instance should now load successfully at https://yourdomain.com. Follow the setup steps in the interface to complete your initial setup.

Security Recommendations
Public servers should always be secure. The following practices are recommended:
- Regularly apply updates and security patches.
- Set strong passwords and control user access.
- Monitor server logs for suspicious activity.
- Install tools like Fail2ban for extra security.
Updating your n8n Installation
When you want to update your n8n instance, simply run:
sudo docker compose pull
sudo docker compose up -d
Docker will download updated versions automatically and replace your current containers.
Cost Comparison with Other Providers
Self-hosting n8n typically results in lower cost compared to hosted services:
| Provider | vCPU | RAM | Disk | Monthly Cost |
|---|---|---|---|---|
| Render.com | 1 | 2 GB | 40 GB | ~$35 |
| Fly.io | 2 | 2 GB | 40 GB | ~$17-20 |
| Railway | 2 | 2 GB | 40 GB | ~$15-30 |
| Sliplane.io | 2 | 2 GB | 40 GB | ~€9.50 flat |
| Hetzner Cloud (self-hosted) | 2 | 2 GB | 40 GB | ~€5-10/month |
You maintain complete control and avoid additional usage-based charges by self-hosting. But of course there is no free lunch and you're now responsible for managing your own server!
Is anything missing with a self-hosted n8n?
Self-hosted n8n (community edition) misses some features included in the official hosted version, but generally provides everything you need. You can check the complete differences on the n8n website.
Now you have your own self-hosted n8n instance running on Ubuntu! Time to start automating your workflows.
FAQ
Can I self-host n8n for free?
n8n Community Edition is free to self-host, but production hosting still costs money. You need a server, storage, backups, monitoring, and your own time for updates and security.
Is SQLite enough for self-hosted n8n?
SQLite is fine for small personal setups and simple workflows. For heavier production use, multiple users, or queue mode, use PostgreSQL instead.
Do I need a domain for self-hosted n8n?
For production, yes. A domain makes HTTPS and webhook URLs much easier. Caddy can automatically issue certificates once the domain points to your server.
How do I update self-hosted n8n?
Run sudo docker compose pull and then sudo docker compose up -d. Before updating important production instances, make sure you have a backup of your n8n volume and credentials encryption key.
What is the easiest way to self-host n8n?
The easiest path is to use a managed container platform like Sliplane. You still get your own n8n instance, but you do not have to configure Ubuntu, Caddy, Docker, firewalls, and backups manually.
Want the same n8n instance without maintaining the Ubuntu server? Deploy n8n on Sliplane or compare options in n8n pricing in 2026.