How to Install n8n on Ubuntu VPS (with Domain & SSL)
π‘ Need help setting this up? Click here for a done-for-you service.
π Introduction
Want to self-host n8n, the powerful open-source automation tool?
In this guide, youβll learn how to install n8n on an Ubuntu VPS, configure a custom domain, secure it with SSL, and run it as a background system service using Nginx as a reverse proxy.
This tutorial is perfect for freelancers, devs, and small teams who want full control over their automation workflows.
β Prerequisites
Before you begin, make sure you have:
- An Ubuntu VPS (20.04 LTS or newer)
- A registered domain pointing to your VPS IP
- SSH access with
sudo
privileges - Basic knowledge of the Linux terminal
π§ Step 1: Update Your System
sudo apt update && sudo apt upgrade -y
π§ Step 2: Install Node.js (v18 LTS)
n8n requires Node.js. Install it via NodeSource:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
Verify it:
node -v
npm -v
π§ Step 3: Install n8n Globally
sudo npm install n8n -g
π§ Step 4: Run n8n as a Systemd Service
Create a service file:
sudo nano /etc/systemd/system/n8n.service
Paste and update the following:
[Unit]
Description=n8n workflow automation
After=network.target
[Service]
Type=simple
User=YOUR_USERNAME
Environment=N8N_HOST=your-domain.com
Environment=N8N_PORT=5678
Environment=N8N_PROTOCOL=https
Environment=NODE_ENV=production
ExecStart=/usr/bin/n8n start
Restart=on-failure
[Install]
WantedBy=multi-user.target
Then enable it:
sudo systemctl enable n8n
sudo systemctl start n8n
π Step 5: Set Up Nginx Reverse Proxy
Install Nginx:
sudo apt install nginx -y
Create a config file:
sudo nano /etc/nginx/sites-available/n8n
Paste this (replace domain):
server {
listen 80;
server_name your-domain.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 and restart:
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
π Step 6: Secure with SSL (Letβs Encrypt)
Install Certbot:
sudo apt install certbot python3-certbot-nginx -y
Generate your certificate:
sudo certbot --nginx -d your-domain.com
Done! HTTPS is now active π
π Step 7: Access Your n8n Dashboard
Visit: https://your-domain.com Youβll be prompted to set up your admin account. From here, you can start building automated workflows.
π― Final Checklist
β n8n running as a background service
β Accessible via your own domain
β Secured with SSL (HTTPS)
β Ready for workflow building
π Next Steps
- π Configure
.env
for sensitive credentials - πΎ Set up regular backups
- π‘οΈ Harden your VPS with
fail2ban
andufw
- π Monitor logs with
journalctl -u n8n
π Need Help Self-Hosting n8n?
I offer a complete n8n installation service, including:
- β VPS setup (Ubuntu/Windows/local)
- β Domain + SSL + reverse proxy
- β Optional Postgres & backup configuration
π Get started now β typically completed in just a few hours.