Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  How-Tos  >  How to Install n8n on Ubuntu | Step-by-Step Setup Guide

How to Install n8n on Ubuntu | Step-by-Step Setup Guide

 3 min

n8n is an open-source automated workflow software that creates seamless connections between apps and APIs. Its node-centric design aids enterprises and developers to automate mundane operations and orchestrating complex workflows. When you self-host n8n on a VPS, you gain complete control and flexibility over your automations.

This guide aims to explain fully how to install n8n on Ubuntu and run it on your own self-hosted server.

Recommended Blog: How to Install n8n? A Step-by-Step Guide for Self-Hosted Workflow Automation

Prerequisites

Before beginning the n8n setup guide on Ubuntu installation, please verify that the system meets the following specifications.

A server with Ubuntu version 20.04 or higher
A non-root user with sudo privileges
Node.js (>= 18) with npm
Docker with Docker Compose, its optional but recommended for production
Fundamental understanding of the command line of the Operating System

Steps to Install n8n on Ubuntu

Step 1: Update and Upgrade Ubuntu

First, complete the system’s package list to ensure everything is current.

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js and npm

n8n requires Node.js (version 18 or later). Use the NodeSource repository to install Node.js.

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

Confirm installation is done via:

node -v
npm -v

Step 3 – Install n8n Globally

Use npm to install n8n on your server and set it for global usage.

sudo npm install n8n -g

It is possible to confirm the installation of n8n via:

n8n --version 

Step 4: Run n8n

Next, after the installation step, n8n can be started with the following:

n8n

n8n can be accessed for usage on port 5678 with default settings. Open the browser and go to the following address: http://your-server-ip:5678

Step 5: Set n8n for Persistent Access

To ensure n8n runs continuously in the background, you need to use PM2 a process manager for Node.js. To install PM2 use the command below.

sudo npm install -g pm2

To start n8n with PM2, use the command below.

pm2 start n8n

After running the below codes, your n8n will start automatically after a system reboot.

pm2 startup

pm2 save

Step 6: Run n8n with Docker (Optional)

In case you want to use a containerized form of deployment, you can install n8n using the Docker option. To install Docker along with Docker Compose, use the following:

sudo apt install docker.io docker-compose -y

To run the n8n Container, use the below command:

docker run -it --rm -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n

Step 7: Use a Reverse Proxy to Secure n8n

In a production environment, it is best practice to set up a reverse proxy with SSL/TLS. To install NGINX, use the command below:

sudo apt install nginx -y

Set NGINX to proxy requests from port 80/443 to 5678. Then, set up SSL using Let’s Encrypt with Certbot.

Step 8: Access the n8n Dashboard

Open your web browser and type: “http://your-domain.com”

If everything is set up correctly, you should see your n8n workflow automation dashboard that is running on the Ubuntu server.

Conclusion

Congratulations on finishing n8n’s Ubuntu installation.

You can now self-host n8n and customize automation workflows for your projects using this n8n setup guide on Ubuntu. n8n can be executed in multiple ways, such as Node.js, PM2, and Docker. No matter how you choose to run it, n8n will always ensure scalability and flexible automated workflows on your Ubuntu server.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.