Knowledgebase > Application Installs > How to Install n8n in CloudPanel v2 on Ubuntu 24.04
How to Install n8n in CloudPanel v2 on Ubuntu 24.04 / 22.04
n8n is a free and source-available workflow automation tool. It enables you to connect various web services and APIs to create powerful, automated workflows with a visual, node-based editor. This guide will walk you through installing n8n on a server running CloudPanel v2 and Ubuntu 24.04.
Prerequisites
Before you begin the installation, make sure you have the following:
- A server running a fresh, minimal installation of Ubuntu 24.04.
- root access or a user with
sudo
privileges. - CloudPanel v2 installed and running on your server.
- A registered domain name pointed to your server's IP address that you will use for n8n (e.g.,
n8n.yourdomain.com
).
Don't have a server yet? Get a powerful NVMe VPS from VPS Server to get started. Our high-performance virtual private servers are perfect for hosting your applications.
Hardware Requirements
Ensure your server meets these minimum hardware requirements for n8n to run smoothly:
- CPU: 1 vCore
- RAM: 2 GB
- Disk Space: 20 GB
Step 1: Prepare Your Server
First, connect to your server via SSH. Once logged in, update your system's package lists and upgrade any existing packages to their latest versions. This ensures that you have the latest security patches and dependencies.
sudo apt-get update && sudo apt-get upgrade -y
Next, install curl which is needed to download the Node.js setup script.
sudo apt-get install -y curl
Step 2: Install Node.js
n8n is built on Node.js, so you need to install it first. We will use the NodeSource repository to install the latest LTS (Long-Term Support) version of Node.js.
Download and execute the NodeSource setup script for the latest Node.js LTS version:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
Now, install Node.js:
sudo apt-get install -y nodejs
Verify the installation by checking the versions of Node.js and npm:
node -v
npm -v
Step 3: Install n8n
With Node.js installed, you can now install n8n globally using npm (Node Package Manager). The -g
flag ensures the package is installed system-wide.
sudo npm install -g n8n
Step 4: Create a systemd Service for n8n
To ensure n8n runs continuously and restarts automatically on server reboots or crashes, we will set it up as a systemd service.
Create a new service file for n8n:
sudo nano /etc/systemd/system/n8n.service
Paste the following configuration into the file. It's recommended to run n8n under a non-root user for security. In this example, we use the root
user for simplicity, but you can create a dedicated user and specify it in the `User` field.
[Unit]
Description=n8n workflow automation
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/bin/n8n
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Save and close the file. Then, reload the systemd daemon to recognize the new service:
sudo systemctl daemon-reload
Start the n8n service:
sudo systemctl start n8n
Enable the n8n service to start on boot:
sudo systemctl enable n8n
You can check the status of the n8n service to ensure it's running correctly:
sudo systemctl status n8n
By default, n8n listens on port 5678
.
Step 5: Configure Reverse Proxy in CloudPanel
Now we will set up a site in CloudPanel to act as a reverse proxy, allowing you to access n8n through your domain with a secure SSL connection.
- Log in to your CloudPanel dashboard.
- Navigate to Sites and click on + Add Site.
- Select Create a Reverse Proxy.
[Screenshot: CloudPanel Add Site selection]
- Enter your subdomain for n8n (e.g.,
n8n.yourdomain.com
) in the Domain Name field. - In the Reverse Proxy URL field, enter
http://127.0.0.1:5678
. - Click on Create.
- Enter your subdomain for n8n (e.g.,
[Screenshot: CloudPanel Reverse Proxy settings]
- After the site is created, go to its management page and issue a Let's Encrypt SSL certificate for it.
You should now be able to access the n8n web interface by navigating to https://n8n.yourdomain.com
. The first time you access it, you will be prompted to set up an owner account for n8n.
[Screenshot: n8n setup screen]
Complete Installation Script
For a fully automated setup, you can use the following bash script. This script will update your server, install Node.js and n8n, and create the systemd service.
#!/bin/bash
#
# n8n Installer for Ubuntu 24.04
#
# This script will update the server, install Node.js, n8n, and set up a systemd service.
# It is intended for a fresh Ubuntu 24.04 installation with CloudPanel v2 already installed.
# Ensure the script is run as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root. Please use sudo." >&2
exit 1
fi
# Set frontend to noninteractive to avoid prompts
export DEBIAN_FRONTEND=noninteractive
# Update and upgrade the system
echo "--> Updating and upgrading the system..."
apt-get update && apt-get upgrade -y
# Install prerequisite packages
echo "--> Installing prerequisite packages..."
apt-get install -y curl
# Install Node.js LTS
echo "--> Installing Node.js LTS from NodeSource..."
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs
# Install n8n globally
echo "--> Installing n8n..."
npm install -g n8n
# Create systemd service file for n8n
echo "--> Creating systemd service for n8n..."
cat < /etc/systemd/system/n8n.service
[Unit]
Description=n8n workflow automation
After=network.target
[Service]
Type=simple
User=root
ExecStart=/usr/bin/n8n
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
# Reload systemd, enable and start n8n service
echo "--> Starting and enabling n8n service..."
systemctl daemon-reload
systemctl enable n8n
systemctl start n8n
# Display completion message
echo "--> n8n installation script has finished."
echo "You can check the status with: sudo systemctl status n8n"
echo "Next steps:"
echo "1. Log in to CloudPanel and create a Reverse Proxy site for your n8n domain (e.g., n8n.yourdomain.com)."
echo "2. Set the Reverse Proxy URL to http://127.0.0.1:5678"
echo "3. Issue an SSL certificate for the site in CloudPanel."
echo "4. Access your n8n instance at https://n8n.yourdomain.com"
To use this script:
- Save the code to a file named
install_n8n.sh
. - Make the script executable:
chmod +x install_n8n.sh
. - Run the script with sudo:
sudo ./install_n8n.sh
.
Ready to get started with workflow automation? Create a new server on VPS Server and install n8n today!