Why Self-Host n8n on a VPS?
n8n is one of the most powerful open-source workflow automation tools available today. While the cloud version is convenient, self-hosting n8n on a VPS gives you unlimited workflows, full data privacy, and no monthly per-execution fees. You own the server. You own the data. You own the process.
In this guide, you will set up a fully functional n8n instance on a VPS using Docker and Docker Compose, secure it with an SSL certificate, and have it running as a persistent background service — all within about 30 minutes.
What You Need Before You Start
- A VPS with at least 1 GB RAM and 1 vCPU (2 GB recommended) — providers like hostinger or netcup are solid choices
- A domain name pointed to your VPS IP address
- Ubuntu 22.04 LTS (recommended OS)
- Basic SSH access and terminal knowledge
Step 1 — Set Up Your VPS
Log into your VPS via SSH. If you're using hostinger or netcup, you can access the root credentials directly from the control panel.
Start by updating the system packages:
apt update && apt upgrade -y
Then create a new non-root user for added security:
adduser n8nuser
usermod -aG sudo n8nuser
Switch to that user for all remaining steps:
su - n8nuser
Step 2 — Install Docker and Docker Compose
Docker is the cleanest way to run n8n on a VPS. It isolates the application, makes updates simple, and avoids dependency conflicts.
sudo apt install docker.io docker-compose -y
sudo systemctl enable docker
sudo systemctl start docker
Verify Docker is running correctly:
docker --version
Step 3 — Create the Docker Compose File
Create a new directory for your n8n setup:
mkdir ~/n8n && cd ~/n8n
Now create a docker-compose.yml file:
nano docker-compose.yml
Paste the following configuration:
version: '3.8'
services:
n8n:
image: n8nio/n8n
restart: always
ports:
- '5678:5678'
environment:
- N8N_HOST=yourdomain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://yourdomain.com/
- GENERIC_TIMEZONE=Europe/Berlin
volumes:
- ~/.n8n:/home/node/.n8n
Replace yourdomain.com with your actual domain. Save and exit with CTRL+X → Y → Enter.
Step 4 — Set Up a Reverse Proxy with Nginx and SSL
To make n8n accessible via HTTPS, you need a reverse proxy. Install Nginx and Certbot:
sudo apt install nginx certbot python3-certbot-nginx -y
Create a new Nginx site configuration:
sudo nano /etc/nginx/sites-available/n8n
Add the following:
server {
server_name yourdomain.com;
location / {
proxy_pass http://localhost:5678;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Enable the config and obtain your SSL certificate:
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo certbot --nginx -d yourdomain.com
sudo systemctl reload nginx
Step 5 — Start n8n
Navigate back to your n8n directory and bring the container up:
cd ~/n8n
docker-compose up -d
Check that it is running:
docker ps
You should see the n8n container listed as Up. Open your browser and go to https://yourdomain.com — the n8n setup screen should greet you.
Step 6 — Secure Your Instance
On first launch, n8n will ask you to create an owner account. Use a strong password. Additionally, consider the following security hardening steps:
- Enable basic authentication via environment variables if you want an extra login layer
- Set up UFW firewall: allow only ports 22, 80, and 443
- Keep Docker and n8n updated regularly
Step 7 — Enable Auto-Restart and Keep n8n Running
Because you used restart: always in your Docker Compose file, n8n will automatically restart if the server reboots or crashes. No additional configuration is needed for basic persistence.
To update n8n in the future:
docker-compose pull
docker-compose up -d
Which VPS Provider Should You Choose?
Both hostinger and netcup work excellently for self-hosting n8n. hostinger offers beginner-friendly dashboards and competitive pricing for entry-level VPS plans. netcup is popular in the European developer community for its transparent pricing and high-performance SSD VPS options.
For a lightweight n8n instance running personal or small-team workflows, a 2 GB RAM plan from either hostinger or netcup is more than sufficient.
Final Thoughts
Self-hosting n8n on a VPS puts you firmly in control of your automation stack. No usage limits, no vendor lock-in, no surprise bills. With Docker and Nginx handling the heavy lifting, the setup is reliable, reproducible, and easy to maintain.
Once your instance is live, the real power begins — connect APIs, build multi-step automations, and run workflows on a schedule that you define, on infrastructure that belongs to you.
This post was created with tools we use and recommend: n8n for workflow automation, Turbotic as an AI-native automation alternative, ElevenLabs for AI voiceover, Placid for visual content creation, and Hostinger for reliable VPS hosting. Some links are affiliate links.