How to Install n8n on Ubuntu

By
Bosko Marijan
Published:
August 19, 2025
Topics:

n8n is an open-source workflow automation tool that lets users connect different apps, services, and APIs to automate tasks without extensive coding. It offers a visual editor for building workflows, supports custom integrations, and can run both in the cloud and self-hosted environments.

This guide shows how to install n8n on Ubuntu using Docker, via Node.js, and how to set up a production-ready environment with HTTPS.

How to install n8n on Ubuntu - a tutorial.

Prerequisites

Install n8n on Ubuntu via Docker

Docker provides an easy, isolated environment for running n8n without installing Node.js directly on your system. This method is ideal for users who want to keep n8n and its dependencies isolated from the rest of the system.

It provides a reproducible environment, easy upgrades, and minimal risk of dependency conflicts. It is great for both testing and production if you want a clean separation from your OS.

Step 1: Install Docker and Docker Compose

Before running n8n in containers, you must have Docker and Docker Compose installed. This ensures the application runs in a portable and reproducible environment.

Follow the steps below:

1. Update the package repository information:

sudo apt update

2. Install the required packages:

sudo apt install -y ca-certificates curl gnupg

3. Add the official Docker GPG key:

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

4. Add the Docker repository:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

5. Install Docker and Docker Compose plugin:

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

6. Enable and start Docker:

sudo systemctl enable docker
sudo systemctl start docker

7. Verify the installation:

docker --version
docker compose version
Verify docker installation.

Step 2: Create a Directory for n8n

Create a dedicated directory to store n8n configuration and persistent data. This keeps all related files organized.

mkdir n8n-docker
cd n8n-docker

Step 3: Create a Docker Compose Configuration File

Define the n8n service in a Docker Compose file so you can easily start, stop, and update it. We will use the nano text editor to create the file:

nano docker-compose.yml

Paste the following code in the file:

version: "3.8"

services:
  n8n:
    image: n8nio/n8n
    ports:
      - "5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=securepassword
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

Replace the securepassword variable with your own secure password. Save the file and exit.

Step 4: Start n8n

Run the container in detached mode so it continues running in the background. The command is:

sudo docker compose up -d

Once the container is running, access n8n at:

http://localhost:5678

Log in with the username and password set in your docker-compose.yml configuration file.

To stop n8n, run:

sudo docker compose down

Install n8n on Ubuntu via Node.js

This method installs n8n directly on your system using Node.js and npm. Node.js is a JavaScript runtime built on Chrome's V8 engine, designed for building scalable, high-performance applications.

Note: Learn the difference between npx and npm, how they work, their purposes, and how they behave in practice.

Use the Node.js method to run n8n directly on your operating system without the container overhead, which can be simpler for small-scale deployments or development environments.

Step 1: Install Node.js and npm

The first step is to install Node.js and npm. Follow the steps below:

1. Update package information:

sudo apt update

2. Add the NodeSource repository to get the latest Node.js version required for n8n:

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -

3. Install Node.js with:

sudo apt install nodejs -y

4. Verify the installation with:

node -v
npm -v
Verify Node.js and npm installation.

Step 2: Install n8n Globally

Use npm to install n8n globally so it can be run from any directory:

sudo npm install -g n8n
Install n8n globally with npm.

Wait for the process to complete.

Step 3: Run n8n

Start the application using the n8n command. It listens on port 5678 by default. Enter:

n8n
Run n8n after installation.

Press o to open your browser, and the account setup page opens:

Setting up n8n owner account.

Fill out the required details to set up the n8n owner account. Provide your email, name, last name, choose a password, and click Next. Once you complete the steps, the browser takes you to the n8n dashboard where you can start creating workflows.

n8n workflow dashboard after installation.

Install n8n on Ubuntu Production Server

This method sets up n8n on an Ubuntu server, suitable for production environments. This method is recommended for users deploying n8n for public or team access. Follow the steps in the sections below.

Step 1: Update Server and Install Dependencies

Before installing n8n, update your system and install the required packages:

1. Update the package information and upgrade all packages to avoid dependency conflicts:

sudo apt update && sudo apt upgrade -y

2. Install utilities for package management and HTTPS repository access:

sudo apt install -y curl gnupg apt-transport-https ca-certificates lsb-release

Step 2: Configure Firewall

Configure the ufw firewall to allow SSH and HTTP traffic required for n8n to work. Run the following commands:

sudo ufw allow OpenSSH
sudo ufw allow 5678/tcp
sudo ufw enable
Configure ufw firewall on Ubuntu server.

Step 3: Choose Installation Method

You can install n8n either:

  • Via Docker. Recommended for an isolated, portable setup with minimal host dependencies.
  • Via Node.js. Runs directly on your system, useful for development or when Docker is not preferred.

Follow the steps for your preferred method outlined in the previous sections.

For a production setup, you may want to run n8n behind an Nginx reverse proxy and enable HTTPS with Let's Encrypt. Follow our tutorials on setting up Nginx as a reverse proxy and securing Nginx with Let's Encrypt on Ubuntu for step-by-step guidance.

Conclusion

This guide showed how to set up n8n on Ubuntu 24 using Docker or via a direct Node.js installation. Once installed, you can start building workflows immediately and expand with reverse proxy and HTTPS if deploying in production.

Next, see how to install and use Docker on Ubuntu or install Node.js and npm.

Was this article helpful?
YesNo