How to Install n8n on Your VPS with Ubuntu (Updated Step-by-Step Guide)
Looking to automate tasks, integrate APIs, and build powerful workflows? n8n is a free and open-source automation tool that's perfect to run on your own VPS. In this guide, you'll learn how to install n8n on an Ubuntu server from scratch.
Requirements
Before getting started, make sure you have:
- A VPS with Ubuntu 22.04 (or higher)
- Root access or a user with
sudo
privileges - Node.js and npm installed
- (Optional) A domain or subdomain with SSL for external access
Step 1 – Update your system
sudo apt update && sudo apt upgrade -y
Step 2 – Install Node.js (recommended version by n8n)
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
Step 3 – Install n8n globally
npm install n8n -g
Step 4 – Run n8n
n8n
It will be available by default at:http://your-ip:5678
Step 5 – Run n8n in the background with PM2
npm install pm2 -g
pm2 start n8n
pm2 startup
pm2 save
(Optional) Set up a subdomain with SSL using NGINX + Certbot
Want to use a domain like automation.yourdomain.com
?
Install NGINX:
sudo apt install nginx -y
Configure reverse proxy and enable SSL with Certbot:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx
Security and authentication
You can protect your n8n instance with basic auth using environment variables:
export N8N_BASIC_AUTH_ACTIVE=true
export N8N_BASIC_AUTH_USER=your_user
export N8N_BASIC_AUTH_PASSWORD=your_secure_password
Ready to automate
You can now start building visual workflows with n8n!
Integrate with:
- Gmail
- Telegram
- External APIs
- Spreadsheets and databases
BH Servers clients get specialized support
By running n8n on a BH Servers VPS, you get access to:
- Support in English
- Optimized performance
- DDoS protection