Hostomy Blog

How to Install n8n and Self-Host on Ubuntu Server

Jul 13, 2025

By Rahul Mukati

Rahul Mukati
How to Install n8n and Self-Host on Ubuntu Server

In the world of workflow automation, n8n stands out as a powerful, open-source alternative to Zapier. With no restrictions on workflows, full data privacy, and complete customization, it's no surprise developers and businesses are choosing to self-host n8n.

In this tutorial, we’ll show you how to install n8n on an Ubuntu server using Node.js (without Docker). Whether you’re deploying on a VPS or dedicated server (like those offered by Hostomy), this guide has everything you need.

Why Self-Host n8n?

Before diving into installation, here’s why self-hosting n8n makes sense:

  • Full data privacy – Your data stays on your server.
  • No usage limits – No per-workflow or per-user restrictions.
  • More customization – Install custom nodes, add plugins, and scale as needed.

Whether you're automating marketing tasks, syncing data between platforms, or building internal tools — self-hosted n8n on Ubuntu gives you power and flexibility.

Prerequisites

Ensure you have the following:

  • Ubuntu 20.04 or 22.04
  • Root or sudo access
  • Node.js (v22 LTS recommended)
  • A domain name (for HTTPS, optional but recommended)

Step 1: Update Your Server

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js and npm

Use NodeSource to install the latest LTS version (v22.x):

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs build-essential

Verify versions:

node -v
npm -v

Step 3: Install n8n Globally

sudo npm install -g n8n

This will make the n8n command available system-wide.

Step 4: Set Environment Variables

We’ll use environment variables to configure authentication, port, host, and webhook URL.

Create a .env file in your home directory:

nano ~/.n8n.env

Paste the following (update values as needed):

N8N_PORT=5678
N8N_HOST=yourdomain.com
WEBHOOK_URL=https://yourdomain.com/
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=strongpassword

Step 5: Run n8n with PM2 (Process Manager)

We’ll use PM2 to keep n8n running in the background and auto-restart it on reboot.

Install PM2:

sudo npm install -g pm2

Start n8n with environment file:

pm2 start n8n --env ~/.n8n.env --name n8n
PM2 will load the environment and run n8n in the background.

Save the process list and enable startup:

pm2 save
pm2 startup

Follow the printed instructions to complete startup setup (usually copy-paste a sudo command).

Step 6: Access n8n in Your Browser

If you're not using a domain, access it via:

http://your_server_ip:5678

If you’re using a domain and want HTTPS, proceed to the next step.

Security Best Practices

  • Use strong credentials for basic auth
  • Enable SSL (HTTPS) — don’t expose port 5678 publicly
  • Limit access to the n8n process via firewall or IP allowlists

Need a Fast VPS for Hosting n8n?

At Hostomy, our blazing-fast SSD-based VPS servers are perfect for self-hosting tools like n8n. With full root access, instant deployment, and optimized Ubuntu stacks — your automation setup will be smooth and secure.Explore Hostomy VPS Hosting

Start Automating Your Workflows Today!

You’ve now successfully installed and self-hosted n8n on Ubuntu using Node.js — with full control, no containers, and complete freedom.

Whether you're automating email parsing, syncing CRMs, or managing internal alerts — n8n gives you unlimited flexibility.

Host it your way. Host it with Hostomy.