Summarize this blog post with:
n8n is a powerful open-source workflow automation tool that lets you connect apps, automate tasks, and build AI-powered pipelines — all self-hosted on your own server. In this guide, we walk you through setting up n8n on an AWS EC2 Ubuntu instance with a custom subdomain, HTTPS, and PM2 for auto-restart.
Prerequisites
- Amazon EC2 instance running Ubuntu (Amazon Linux 2 or similar)
- SSH access to your instance
- Security Group with port 5678 open for n8n
- A domain or subdomain (e.g., n8n.example.com) with an A record pointing to your EC2 public IP
- nginx installed on the server
Step 1 – Update & Install Essentials
sudo apt update -y
sudo apt upgrade -y
sudo apt install curl nginx unzip -yStep 2 – Install Node.js (v18)
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
node -v
npm -vStep 3 – Install PM2 Globally
sudo npm install pm2 -gStep 4 – Install n8n
sudo npm install -g n8nStep 5 – Start n8n with PM2
Use PM2 to start n8n so it runs in the background and restarts automatically on reboot.
pm2 start n8n
pm2 startup
pm2 saveOptional: Set environment variables before starting — export N8N_PORT=5678 and export N8N_HOST=localhost — to control which port and host n8n listens on.
Step 6 – Configure Nginx Reverse Proxy
Create an Nginx server block to proxy requests from your subdomain to n8n running on localhost:5678.
sudo nano /etc/nginx/sites-available/n8nPaste the following configuration (replace n8n.example.com with your actual subdomain):
server {
server_name n8n.example.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_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
if ($host = n8n.example.com) {
return 301 https://$host$request_uri;
}
listen 80;
server_name n8n.example.com;
return 404;
}Enable the configuration and restart Nginx:
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginxStep 7 – Enable HTTPS with Let's Encrypt (Optional)
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d n8n.example.comWhen prompted, choose redirect to automatically enforce HTTPS. Certbot will update your Nginx config and renew the certificate automatically.
Step 8 – Verify Everything is Running
pm2 list
sudo systemctl status nginx
curl -I http://localhost:5678Visit https://n8n.example.com in your browser — you should see the n8n login screen.
Useful PM2 Commands
- pm2 logs n8n — View live n8n logs
- pm2 restart n8n — Restart the n8n process
- pm2 stop n8n — Stop n8n without removing it from PM2
- pm2 list — Check status of all PM2-managed processes
You're done! n8n is now running live on your subdomain with HTTPS enabled and PM2 handling auto-restart on server reboot.
Need help setting up n8n workflows or integrating AI automation into your business? BitPixel Coders builds custom n8n automation pipelines and AI agents — get in touch for a free strategy consultation.
Get a Free Consultation →Frequently Asked Questions
With this guide, the full setup — including Node.js, PM2, Nginx, and SSL — takes approximately 15–20 minutes on a fresh Ubuntu EC2 instance.
Yes. A t2.micro or t3.micro instance (1 vCPU, 1 GB RAM) works fine for personal use and small workflows. For production with many concurrent executions, use a t3.small or larger.
Run: sudo npm update -g n8n followed by pm2 restart n8n. Always check the n8n release notes for breaking changes before updating a production instance.
Yes, when configured correctly. Use Nginx as a reverse proxy with SSL, enable n8n built-in authentication, and block direct access to port 5678 via your EC2 Security Group.
n8n is open-source and self-hostable — you own your data and pay no per-execution fees. Zapier is cloud-only SaaS with per-task pricing. n8n also supports custom JavaScript and Python inside nodes, which Zapier does not.
Related Guides
- Building Automation Workflows with n8n: A Complete Guide
- AI Automation Trends 2026 – What Every Business Needs to Know
- Building AI Agents That Actually Work: A Practical Guide for 2026