n8n Self-Hosting Setup Guide (DigitalOcean)
Full walkthrough: server provisioning, Ubuntu setup, n8n installation, SSL config, NGINX reverse proxy. Non-technical language.
n8n Self-Hosting Setup Guide (DigitalOcean)
You need a self-hosted n8n instance that won't crash during peak workflow runs and won't expose your client data to third-party cloud services. This guide walks you through deploying n8n on DigitalOcean with proper SSL, process management, and security hardening.
Total setup time: 45-60 minutes. Monthly cost: $12-24 depending on your droplet size.
What You Need Before Starting
Required:
- DigitalOcean account with payment method added
- Domain name pointed to DigitalOcean nameservers (or ability to create A records)
- SSH key pair generated on your local machine
- Terminal access (Terminal on Mac, PowerShell on Windows, or any SSH client)
Recommended:
- 1Password or similar for storing server credentials
- Basic understanding of command-line navigation (cd, ls, nano)
Step 1: Create and Configure Your Droplet
- Log into DigitalOcean and click the green "Create" button in the top right
- Select "Droplets" from the dropdown menu
- Configure your droplet with these exact settings:
Image Selection:
- Choose "Ubuntu 22.04 (LTS) x64" under the Distributions tab
- Do not use Ubuntu 20.04 or older versions
Droplet Size:
- Select "Basic" plan type
- Choose "Regular" CPU option
- Pick the $12/month tier (2 GB RAM, 1 CPU, 50 GB SSD)
- The $6/month option will cause memory issues under load
Datacenter Region:
- Select the region closest to your primary users
- For US-based firms: New York 1 or San Francisco 3
- For international: London, Frankfurt, or Singapore
Authentication:
- Select "SSH keys" (not password)
- Click "New SSH Key" if you haven't added yours yet
- Paste your public key content (found in
~/.ssh/id_rsa.pubon your local machine) - Name it something identifiable like "MacBook-Pro-2024"
Additional Options:
- Enable "IPv6"
- Enable "Monitoring" (free)
- Skip "Droplet Backups" for now (adds 20% to cost)
Hostname:
- Set a clear hostname like "n8n-production" or "automation-server"
Click "Create Droplet" and wait 60 seconds for provisioning
Copy the IP address shown in your Droplets list (format: 164.90.xxx.xxx)
Step 2: Point Your Domain to the Server
Before connecting, set up DNS so you can access n8n via a proper domain.
- Log into your domain registrar (Namecheap, GoDaddy, Cloudflare, etc.)
- Navigate to DNS settings for your domain
- Create an A record:
- Host: automation (or whatever subdomain you want)
- Value: Your droplet IP address
- TTL: 300 (5 minutes)
- Save the record
DNS propagation takes 5-30 minutes. Continue with the next steps while you wait.
Step 3: Initial Server Connection and Security Setup
- Open your terminal and connect to the server:
ssh root@YOUR_DROPLET_IP
Replace YOUR_DROPLET_IP with the actual IP address from Step 1.
You'll see a message asking to verify the host fingerprint. Type
yesand press Enter.Update the system packages:
apt update && apt upgrade -y
This takes 2-3 minutes. Let it complete fully.
- Create a non-root user for running n8n:
adduser n8nuser
Set a strong password when prompted. Press Enter through the other fields (Full Name, etc.).
- Add the new user to the sudo group:
usermod -aG sudo n8nuser
- Copy SSH access to the new user:
rsync --archive --chown=n8nuser:n8nuser ~/.ssh /home/n8nuser
- Switch to the new user:
su - n8nuser
You're now operating as n8nuser instead of root. This is safer for day-to-day operations.
Step 4: Install Node.js and Required Dependencies
n8n requires Node.js 18.x or higher. Ubuntu's default repositories have outdated versions, so we'll use NodeSource.
- Install Node.js 20.x (current LTS):
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
- Verify the installation:
node --version
npm --version
You should see v20.x.x for Node and 10.x.x for npm.
- Install build tools needed for some n8n dependencies:
sudo apt install -y build-essential python3
Step 5: Install n8n Globally
- Install n8n as a global npm package:
sudo npm install -g n8n
This takes 3-5 minutes and installs n8n system-wide.
- Verify n8n is installed:
n8n --version
You should see the current version number (1.x.x or higher).
Step 6: Configure n8n Environment Variables
n8n uses environment variables for configuration. We'll create a dedicated config file.
- Create a directory for n8n data:
mkdir -p ~/.n8n
- Create an environment file:
nano ~/.n8n/n8n.env
- Paste this configuration (replace placeholders with your actual values):
# Basic Configuration
N8N_HOST=0.0.0.0
N8N_PORT=5678
N8N_PROTOCOL=https
WEBHOOK_URL=https://automation.yourdomain.com/
# Security
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=YourSecurePassword123!
# Database (SQLite for single-server setups)
DB_TYPE=sqlite
DB_SQLITE_DATABASE=/home/n8nuser/.n8n/database.sqlite
# Timezone
GENERIC_TIMEZONE=America/New_York
# Execution
EXECUTIONS_DATA_SAVE_ON_ERROR=all
EXECUTIONS_DATA_SAVE_ON_SUCCESS=all
EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=true
Replace automation.yourdomain.com with your actual domain from Step 2.
- Save the file (Ctrl+X, then Y, then Enter)
Step 7: Set Up n8n as a System Service
Running n8n directly in the terminal means it stops when you disconnect. We'll use systemd to keep it running permanently.
- Create a systemd service file:
sudo nano /etc/systemd/system/n8n.service
- Paste this configuration:
[Unit]
Description=n8n workflow automation
After=network.target
[Service]
Type=simple
User=n8nuser
EnvironmentFile=/home/n8nuser/.n8n/n8n.env
ExecStart=/usr/bin/n8n start
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Save the file (Ctrl+X, then Y, then Enter)
Reload systemd and start n8n:
sudo systemctl daemon-reload
sudo systemctl enable n8n
sudo systemctl start n8n
- Check that n8n is running:
sudo systemctl status n8n
You should see "active (running)" in green. Press Q to exit the status view.
Step 8: Install and Configure NGINX Reverse Proxy
NGINX sits in front of n8n to handle SSL certificates and provide better performance.
- Install NGINX:
sudo apt install -y nginx
- Remove the default NGINX configuration:
sudo rm /etc/nginx/sites-enabled/default
- Create a new configuration file for n8n:
sudo nano /etc/nginx/sites-available/n8n
- Paste this configuration (replace
automation.yourdomain.comwith your domain):
server {
listen 80;
server_name automation.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_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;
proxy_cache_bypass $http_upgrade;
# Increase timeouts for long-running workflows
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
send_timeout 300;
}
}
Save the file (Ctrl+X, then Y, then Enter)
Enable the configuration:
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
- Test the NGINX configuration:
sudo nginx -t
You should see "syntax is ok" and "test is successful".
- Restart NGINX:
sudo systemctl restart nginx
Step 9: Install SSL Certificate with Certbot
Let's Encrypt provides free SSL certificates. Certbot automates the entire process.
- Install Certbot and the NGINX plugin:
sudo apt install -y certbot python3-certbot-nginx
- Run Certbot to obtain and install the certificate:
sudo certbot --nginx -d automation.yourdomain.com
When prompted:
- Enter your email address (for renewal notifications)
- Type
Yto agree to terms of service - Type
Nto decline marketing emails (optional) - Certbot will automatically modify your NGINX config and restart the service
Verify SSL is working by visiting
https://automation.yourdomain.comin your browser
You should see the n8n login screen with a valid SSL certificate (padlock icon in the address bar).
- Set up automatic certificate renewal:
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer
Certbot will now automatically renew your certificate before it expires.
Step 10: Configure Firewall Rules
Lock down your server to only allow necessary traffic.
- Install UFW (Uncomplicated Firewall):
sudo apt install -y ufw
- Set default policies:
sudo ufw default deny incoming
sudo ufw default allow outgoing
- Allow SSH, HTTP, and HTTPS:
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
- Enable the firewall:
sudo ufw enable
Type y when prompted.
- Verify firewall status:
sudo ufw status
You should see rules for ports 22, 80, and 443.
Step 11: First Login and Initial Configuration
Open your browser and navigate to
https://automation.yourdomain.comLog in with the credentials you set in Step 6:
- Username: admin
- Password: YourSecurePassword123!
Complete the initial setup wizard:
- Set your owner account email and password (different from basic auth)
- Choose whether to allow telemetry (your choice)
- Skip the "Connect to n8n cloud" option
Create your first workflow to test the installation:
- Click "Add workflow"
- Add a "Schedule Trigger" node (runs on a schedule)
- Add an "HTTP Request" node
- Configure it to GET
https://api.github.com/zen - Connect the nodes and click "Execute Workflow"
If you see a random Zen quote in the output, your n8n instance is fully operational.
Maintenance Commands You'll Need
View n8n logs:
sudo journalctl -u n8n -f
Restart n8n:
sudo systemctl restart n8n
Update n8n to the latest version:
sudo npm update -g n8n
sudo systemctl restart n8n
Check disk space:
df -h
Backup your n8n database:
cp ~/.n8n/database.sqlite ~/n8n-backup-$(date +%Y%m%d).sqlite
Run that backup command weekly and download the file to your local machine via SFTP.
What to Do If Something Goes Wrong
n8n won't start:
Check the logs with sudo journalctl -u n8n -n 50 to see error messages.
Can't access via domain:
Verify DNS propagation with dig automation.yourdomain.com. If it doesn't show your server IP, DNS hasn't propagated yet.
SSL certificate fails: Make sure your domain's A record points to the correct IP and that ports 80 and 443 are open in your firewall.
Workflows time out: Increase the timeout values in the NGINX configuration (Step 8) and restart NGINX.
Your n8n instance is now production-ready. Set up your first real workflow, configure webhook endpoints for external services, and start automating your firm's repetitive tasks.

Reviewed by Revenue Institute
This guide is actively maintained and reviewed by the implementation experts at Revenue Institute. As the creators of The AI Workforce Playbook, we test and deploy these exact frameworks for professional services firms scaling without new headcount.
Revenue Institute
Need help turning this guide into reality? Revenue Institute builds and implements the AI workforce for professional services firms.