How to Host n8n on Your Own Server: Step-by-Step Guide

Host n8n on Your Own Server is one of the most common questions developers and businesses ask when exploring open-source automation. n8n (pronounced “n-eight-n”) has become one of the most popular open-source automation tools, offering flexibility, cost savings, and full control. Unlike closed SaaS platforms such as Zapier or Make, n8n gives you the freedom to self-host on your own server, ensuring full control, cost savings, and data privacy.
But how exactly do you host n8n yourself? In this detailed guide, we’ll walk you through everything you need to know to host n8n on your own server—from requirements and installation to advanced setup, security, and scaling.
– If you’re new to n8n, check out our Complete n8n Automation Guide before diving into hosting.
Why Host n8n on Your Own Server?
Hosting n8n yourself provides several advantages compared to using n8n.cloud (the managed hosted service):
- Full Data Privacy – Keep sensitive business data on your own infrastructure.
- Cost Savings – Free to host, only pay for your server resources.
- Customization – Add custom nodes, integrate with internal systems, and modify the platform.
- Scalability – Scale horizontally with containers and orchestration tools like Kubernetes.
- Control – You decide on updates, configurations, and integrations.
– At DecaSoft Solutions, we often recommend self-hosting for businesses that need custom, enterprise-grade automation at lower costs.
Prerequisites for Hosting n8n
Before we get into the step-by-step guide, here’s what you’ll need:
1. Server Requirements
- OS: Linux (Ubuntu 20.04 LTS recommended), macOS, or Windows Server.
- CPU: 2+ cores recommended.
- RAM: 2–4 GB minimum for production.
- Storage: 20+ GB.
- Network: Stable internet with open ports.
2. Software Requirements
- Node.js (v18 or later recommended).
- npm (Node Package Manager).
- Docker (optional, for containerized deployments).
- Database (PostgreSQL or MySQL for production; SQLite works for testing).
3. Access Requirements
- SSH access to your server.
- Basic terminal/Linux knowledge.
- A domain name (optional but recommended).
Step 1: Preparing to Host n8n on Your Own Server
For this tutorial, let’s assume you’re using Ubuntu 20.04 on a VPS (e.g., DigitalOcean, AWS, Azure, or Google Cloud).
a. Update your packages:
sudo apt update && sudo apt upgrade -y
b. Install Node.js (using NodeSource):
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs
c. Verify installation:
node -v npm -v
Step 2: Installing and Running n8n on Your Own Server
There are two main methods:
Option A: Install via npm (simple setup)
npm install n8n -g
Start n8n:
n8n
By default, n8n runs at:
– http://localhost:5678
Option B: Install via Docker (recommended for production)
a. Install Docker and Docker Compose:
sudo apt install docker.io docker-compose -y
b. Create a Docker Compose file:
version: '3'
services:
n8n:
image: n8nio/n8n
ports:
- "5678:5678"
volumes:
- ./n8n_data:/home/node/.n8n
c. Start n8n:
docker-compose up -d
– Docker keeps your installation clean and makes scaling/updating easier.
Step 3: Configuring n8n
To make n8n production-ready, configure environment variables.
Example .env
file:
# Basic settings
N8N_HOST=mydomain.com
N8N_PORT=5678
N8N_PROTOCOL=https
# Database
DB_TYPE=postgresdb
DB_POSTGRESDB_DATABASE=n8n
DB_POSTGRESDB_HOST=localhost
DB_POSTGRESDB_USER=n8n
DB_POSTGRESDB_PASSWORD=strongpassword
DB_POSTGRESDB_PORT=5432
# Authentication
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=securepassword
Restart n8n after making changes.
Step 4: Securing Your n8n Instance
1. Reverse Proxy with Nginx + SSL
Install Nginx:
sudo apt install nginx -y
Set up reverse proxy + SSL with Let’s Encrypt. This makes n8n accessible via https://yourdomain.com
.
2. Enable Basic Authentication
As shown in the .env
config above, secure your n8n instance with username and password.
3. Firewall Rules
Allow only required ports (80, 443, 22). Block 5678 externally.
Step 5: Setting Up Database (Optional but Recommended)
For testing, n8n uses SQLite by default. For production, use PostgreSQL or MySQL.
PostgreSQL example:
sudo apt install postgresql postgresql-contrib -y
sudo -u postgres psql
CREATE DATABASE n8n;
CREATE USER n8n WITH ENCRYPTED PASSWORD 'strongpassword';
GRANT ALL PRIVILEGES ON DATABASE n8n TO n8n;
Update .env
with database details.
Step 6: Running n8n in the Background
Use PM2 (process manager for Node.js):
npm install pm2 -g
pm2 start n8n
pm2 save
pm2 startup
Or use systemd services for auto-start on reboot.
Step 7: Scaling n8n
For larger deployments:
- Use Docker Swarm or Kubernetes for clustering.
- Connect n8n with Redis for job queue management.
- Deploy behind a load balancer for high availability.
– DecaSoft Solutions helps enterprises design scalable, production-ready n8n hosting architectures.
Common Issues When Hosting n8n
- Port Conflicts – Ensure 5678 is not used by another service.
- Database Errors – Check DB credentials and firewall.
- SSL Issues – Use Let’s Encrypt and renew certificates regularly.
- Performance Bottlenecks – Scale CPU/RAM or switch to Kubernetes.
Self-Hosting vs Cloud: Should You Host n8n on Your Own Server?
Feature | Self-Hosting n8n | n8n.cloud |
---|---|---|
Cost | Free (server costs only) | Paid (starts ~$20/mo) |
Data Privacy | Full control | Managed by n8n |
Customization | Unlimited | Limited |
Setup Effort | High | Low |
Scalability | Manual | Managed |
– For SMBs, n8n.cloud is easier. For technical teams and enterprises, self-hosting n8n offers greater flexibility and long-term savings.
Final Thoughts
Learning how to host n8n on your own server opens up endless opportunities. You get the power of automation combined with the freedom of open-source—without the cost of commercial SaaS tools.
At DecaSoft Solutions, we help businesses deploy and manage n8n hosting—whether on cloud servers, Kubernetes clusters, or on-prem infrastructure.
– Want to self-host n8n but don’t have the time or team? Contact DecaSoft Solutions and let our experts set it up for you.