Self-hosting your automation is the ultimate way to maintain data privacy, gain unlimited execution runs, and bypass Zapier’s costly subscription tiers. Here is a complete guide to installing and running n8n.io on an Ubuntu server.

Prerequisites#
Before starting the installation, ensure you have:
- A Linux machine running Ubuntu (Ubuntu 20.04 LTS or newer recommended).
- A user with sudo administrative privileges.
Manual Installation Steps#
Follow these steps to install and start n8n manually.
Step 1: Update the OS Packages#
Start by updating your local package lists to ensure you have the latest software indexes:
sudo apt update && sudo apt upgrade -yStep 2: Install Node.js and NPM#
n8n is built on Node.js and requires an active LTS runtime. We will install the latest supported packages:
sudo apt install -y nodejs npmStep 3: Install n8n Globally#
Install n8n globally on your system using Node’s package manager:
sudo npm install -g n8nStep 4: Start the Service#
You can start n8n directly from the terminal to test your installation:
n8n startOnce running, navigate your browser to http://your-server-ip:5678 (or http://localhost:5678 if installing locally) to access the editor.
Production Setup: Install via Automated Bash Script#
Running n8n directly in the terminal works for testing, but in production, you want it to run as a background service that automatically restarts if the server reboots.
The following script automates the installation of Node.js 20 (LTS), installs n8n globally, and registers it as a standard systemd service.
1. Create the Script#
Create a new file named install_n8n.sh and add the following content:
#!/bin/bash
# install_n8n.sh - Install n8n and set up systemd service
# Exit on any error
set -e
echo "Updating system packages..."
sudo apt update
sudo apt install -y curl
echo "Installing Node.js 20 (LTS)..."
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
echo "Installing n8n globally..."
sudo npm install n8n -g
# Prepare configuration directory
mkdir -p ~/.n8n
USER_NAME=$(whoami)
USER_HOME=$(eval echo ~$USER_NAME)
echo "Creating systemd service file..."
cat <<EOL > /tmp/n8n.service
[Unit]
Description=n8n.io - Workflow Automation Tool
After=network.target
[Service]
ExecStart=/usr/bin/env n8n
WorkingDirectory=${USER_HOME}/.n8n
Restart=always
User=${USER_NAME}
Group=${USER_NAME}
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
EOL
sudo mv /tmp/n8n.service /etc/systemd/system/n8n.service
echo "Reloading systemd and enabling service..."
sudo systemctl daemon-reload
sudo systemctl enable n8n
sudo systemctl start n8n
echo "--------------------------------------------------------"
echo "Installation complete! n8n is running as a systemd service."
echo "Check status: sudo systemctl status n8n"
echo "Access interface at http://localhost:5678"
echo "--------------------------------------------------------"2. Make the Script Executable#
Set the execution permissions for the script:
chmod +x install_n8n.sh3. Execute the Script#
Run the automated installation:
./install_n8n.sh5678.What’s your hosting stack?#
Are you hosting n8n on a local home server (like a Raspberry Pi), a cloud VPS, or inside a Docker Swarm? Share your infrastructure and automation workflows in the comments below!

