serverserv serverserv

How to install n8n on Ubuntu, step by step

By Siam Ahmed, software engineer · 7 min read · Updated

There are two good ways to install n8n on Ubuntu: with Docker, which keeps n8n in its own container and makes updates a two-command job, or with npm, which installs n8n directly on the system. Docker is the better default for a server you plan to keep. This guide walks through both, on Ubuntu 22.04 or 24.04, and ends with how to keep n8n running and up to date.

What you need first

You need an Ubuntu 22.04 or 24.04 server (or a computer) you can reach by SSH or terminal, with at least 1 GB of RAM for a small setup — 2 GB or more is comfortable once workflows grow. Our n8n system requirements guide explains how to size the server. You also need about 10 minutes.

Everything below runs as a user with sudo access. Replace example values like the server IP and timezone with your own.

Method 1: install n8n with Docker (recommended)

Install Docker, write one small compose file, and start n8n. Your workflows and data live in a named volume, so they survive updates and restarts.

Step 1 — update the system and install Docker:

sudo apt update && sudo apt upgrade -y
curl -fsSL https://get.docker.com | sudo sh
sudo systemctl enable --now docker

Step 2 — create a folder and a compose file:

mkdir ~/n8n && cd ~/n8n
nano docker-compose.yml

Paste this in, changing the timezone to your own:

services:
  n8n:
    image: n8nio/n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - GENERIC_TIMEZONE=Europe/Berlin
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

Step 3 — start n8n:

sudo docker compose up -d

Give it a few seconds, then open http://YOUR-SERVER-IP:5678 in your browser. If the page does not load, check that your server's firewall allows port 5678 (for example sudo ufw allow 5678 if you use UFW).

Method 2: install n8n with npm

The npm route installs n8n as a global Node.js package. It is quick for testing, but you are responsible for keeping it running and updated yourself.

Step 1 — install Node.js 20 LTS:

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

Step 2 — install and start n8n:

sudo npm install -g n8n
n8n start

n8n now runs on port 5678, at http://YOUR-SERVER-IP:5678. It stops when you close the terminal — the next section shows how to keep it alive with PM2.

First login and setup

Whichever method you used, the first visit asks you to create the owner account — an email and a strong password. After that you land in the workflow editor and can build your first workflow. Two things worth doing straight away:

  • Put n8n behind HTTPS before you use it for real work, especially if you connect accounts to it. Our guide to securing an n8n server covers the reverse-proxy and hardening steps.
  • Set the timezone (already in the Docker example above) so scheduled workflows fire at the times you expect.

Keep n8n running

Docker installs restart on their own: the compose file sets restart: unless-stopped, so n8n comes back after a reboot or a crash. For the npm install, use PM2:

sudo npm install -g pm2
pm2 start n8n
pm2 save
pm2 startup

Run the extra command PM2 prints after pm2 startup — that is what makes n8n start again after a reboot.

How to update n8n

On Docker, updating is two commands and your data stays in the volume. On npm, one command reinstalls the latest version. Update regularly — new versions fix bugs and add nodes — and read the release notes first if a workflow is business-critical.

# Docker
cd ~/n8n
sudo docker compose pull
sudo docker compose up -d

# npm
sudo npm install -g n8n@latest

Installing community nodes

Community nodes are extra integrations built by the n8n community and published as npm packages — they extend n8n beyond its built-in nodes. On a self-hosted install you add them from inside n8n: open Settings, choose Community nodes, choose Install, paste the package name from npm, accept the risk notice, and the node appears in your editor.

Two habits keep this safe. Install only packages you trust — a community node runs with the same access as your n8n instance, including your stored credentials. And check the package's npm page before installing: who maintains it, when it was last updated, and whether others are using it. A node that has not been touched in years may break on a current n8n version.

If your install does not offer the Community nodes settings page (some locked-down or multi-instance setups restrict it), your administrator can install packages with npm instead, or the node may already be available as a built-in you have not spotted — search the node panel first.

Running n8n locally vs on a server

Running n8n on your own computer is fine for learning and testing — the npm method above works the same way locally. The catch: your workflows only run while the computer is on and awake. A small server keeps them running around the clock, which is what most automations actually need.

That is why most people who outgrow local testing move n8n to a VPS. A basic Linux KVM VPS is enough to start, and you can install n8n on it with this same guide.

Don't want to install it yourself?

Installing is only the first job — after it come HTTPS, updates, backups and keeping the server healthy. If you would rather skip all of that, serverserv n8n Hosting gives you your own KVM server with n8n already installed and set up free, no limits on workflows or executions, from $8.39 a month on a 3-year term — and the first month is $1 on a monthly plan. You log in and start building workflows; we handle the server underneath.

Questions? Contact our team.

Questions

Can I install n8n on Ubuntu 24.04?

Yes. Both methods in this guide — Docker and npm — work on Ubuntu 22.04 and 24.04 LTS. Docker is the better choice for a server you plan to keep, because updates are two commands and your data lives in its own volume.

How much RAM do I need to install and run n8n?

1 GB of RAM is enough for a small setup and light workflows. 2 GB or more is comfortable once you run many workflows or heavier nodes, and it is what we recommend for a server you rely on.

Is n8n free to install?

Yes. n8n Community Edition is free to self-host under n8n's Sustainable Use Licence. You only pay for the server it runs on — a small VPS is enough to start.

How do I update n8n?

With Docker, run docker compose pull and then docker compose up -d in your n8n folder; your data stays in the volume. With npm, run npm install -g n8n@latest. Check the release notes before updating a server that runs important workflows.

Should I run n8n locally or on a server?

Locally is fine for learning and testing workflows. Move to a server when the workflows need to run around the clock — a local install stops whenever your computer sleeps or switches off, while a VPS keeps everything running.

What are n8n community nodes?

Community nodes are extra integrations built by the n8n community and published as npm packages. In a self-hosted install you can add them from Settings → Community nodes in the editor. They run with the same access as your n8n instance, so install only packages you trust — check who maintains the package and whether it is still updated.

Ready to deploy?

Pick a plan, choose a term and our team sets up your server for you.

See all plansTalk to sales

Need a custom server, bulk pricing or help moving from another host? Our team will build a quote for you.

Plans from $2.99/moSee plans