Install n8n: Full Self-Hosting and Setup Guide for 2025 

Learn how to install n8n on Docker, Ubuntu, macOS, Windows, and locally. Step-by-step self-hosting instructions for 2025.

Updated: 12 Oct, 25 by Ethan Bennett 20 Min

List of content you will read in this article:

If you’re looking for a way to automate your digital workflows intelligently and professionally, but don’t want to pay the monthly fees of SaaS tools like Zapier or Make, n8n is the best choice for you. n8n is an open-source workflow automation platform that allows for self-hosting. In this guide, we’ll walk you through the different ways to install n8n: installing with Docker, installing on Ubuntu Linux or other distributions, installing on macOS and Windows, and installing locally for testing. Stay tuned.

Before installing n8n, you must make sure that your system meets the following minimum hardware and software requirements:

Category

Description

Notes & Recommendations

Hardware

  • Minimum: 2 core CPU - 2 GB RAM- 20 GB disk space
  • recommended: 4 core CPU- 4 to 6 GB RAM- 40 to 80 GB disk space

For testing, even weak systems are sufficient. However, in production environments, the system requirements may be even higher than the recommended mode.

Operating System (OS)

Supported: Ubuntu, Debian, Arch Linux, macOS, Windows

On Arch Linux, you can install via the official AUR package: yay -S n8n.On other systems, install manually using Node.js and npm, or via Docker.

Required Software

  • For Docker setup: You need Docker and Docker Compose.
  • For direct install: You need Node.js v18+ and npm.

LTS versions (such as Node 20.x) are the most stable choice. You can verify versions using: node -v and npm -v.

Database (Optional)

  • Default: SQLite
  • Recommended: PostgreSQL or MariaDB for production environments

You can define the database type in your .env file using DB_TYPE. Example: DB_TYPE=postgresdb.

Network

Default Port: TCP 5678

If using a firewall (like ufw or firewalld), open port 5678:sudo ufw allow 5678/tcp.For secure access, set up SSL with a reverse proxy such as Nginx or Caddy.

Domain / DNS (Proxy)

Custom domain such as n8n.example.com

Point your domain to the server’s IP address, then configure Nginx or Caddy to route traffic from ports 80/443 to port 5678.

The next step is selecting a proper installation method. One can install n8n in multiple ways, such as Docker, a direct installation with npm, or even WSL on Windows. Every method has its own upside,

Installation Method

Advantages

Disadvantages

Docker (on Linux)

Fast and isolated setup; easier maintenance and updates

Requires basic Docker knowledge; adds some container overhead

Native Linux Install (npm)

High performance, no container overhead; ideal for server-side development

Requires manual Node.js and service management; updates can be more complex

macOS (Homebrew/Node)

Easy installation via Homebrew or Docker; great for local development

macOS-only; less suitable for production servers

Windows (Node/WSL)

Simple for Windows users; supports WSL for better compatibility

Path and permission issues in Windows; less stable compared to Docker

Local Installation (npm)

Quick and lightweight for development/testing; no server required

Suitable only for learning/testing; no persistent storage (unless volume set)

Comparison of these methods can help you decide which option is best for you.

One of the most effective and highly suggested methods to set up and use n8n is the Docker way. In this case, the app system is kept totally separated and independent from other services, there are no conflicts with other services. Additionally, it is also easier to upgrade and manage with a direct installation.

Step 1: Ensure that Docker and Docker Compose are installed

Initially, Docker and Docker Compose must be installed and activated on your system. You can verify this by running the commands below in the terminal: 

docker --version

docker compose version

If you get output similar to the following, Docker is installed correctly:

Docker version 27.0.3, build abc123

Docker Compose version v2.27.0

Otherwise, you need to install Docker.

🐳 Installing Docker on Ubuntu/Debian

Run the following commands:

sudo apt update

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

sudo mkdir -p /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

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

sudo apt update

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

Then make sure the Docker service is running with the following command:

sudo systemctl enable docker

sudo systemctl start docker

To check the performance of Docker Compose (in new versions of Docker, Compose is installed as a plugin), run the following command:

docker compose version

If you are using Windows or macOS, you can download and install Docker Desktop from the official site docker.com.

Step 2: Create a Volume to Store Data

To ensure that n8n data is preserved even after the container is stopped or deleted, you need to create a dedicated Docker volume:

docker volume create n8n_data

This volume will contain your settings, workflow history, users, and credentials.

Step 3: Run n8n with Docker

Now you can run n8n in a container. The following command creates a container named n8n and connects port 5678 from inside the container to the host:

docker run -it --rm --name n8n \

-p 5678:5678 \

-v n8n_data:/home/node/.n8n \

docker.n8n.io/n8nio/n8n

Parameter explanation:

  • -p 5678:5678 → Connects port 5678 inside the container to port 5678 on the host.
  • -v n8n_data:/home/node/.n8n → Connects the n8n data path to the created volume.
  • --rm → The container will be automatically deleted after stopping (the data will remain on the volume).

After running this command, the official n8n image will be downloaded from the Docker Hub repository, and the service will be running. Now you can open n8n by going to the following address in your browser:

👉 http://localhost:5678

Or if you are running on a server:

👉 http://<SERVER_IP>:5678

Step 4: Run n8n with Docker Compose

For a more stable and convenient installation, it is better to use Docker Compose. Create a file named docker-compose.yml and put the following content in it:

version: '3.7'

services:

  n8n:

    image: n8nio/n8n

    ports:

      - "5678:5678"

    environment:

      - N8N_BASIC_AUTH_ACTIVE=true

      - N8N_BASIC_AUTH_USER=admin

      - N8N_BASIC_AUTH_PASSWORD=strongpass

      - N8N_HOST=n8n.yourdomain.com

      - WEBHOOK_URL=https://n8n.yourdomain.com

    volumes:

      - n8n_data:/home/node/.n8n

volumes:

  n8n_data:

To run the file:

docker compose up -d

n8n will now run in the background. The environment variables in the environment section are used for security and customization:

  • N8N_BASIC_AUTH_ACTIVE=true → Enable Basic Auth
  • N8N_BASIC_AUTH_USER and N8N_BASIC_AUTH_PASSWORD → Set username and password
  • N8N_HOST and WEBHOOK_URL → Set the domain to use with HTTPS

Once running, you can access n8n via the domain or server IP.

Step 5: Create an Owner Account

When you first run n8n, you will be prompted to create an owner account. Open the address http://localhost:5678 in your browser. A page similar to the one below will be displayed:

Create an Owner Account

Enter your email, select a username, and a password in this step. The Owner role with full system access will be assigned to this account. Then, you can create your first workflow on n8n dashboard, which will be shown to you.

To install n8n on Ubuntu or any other Linux Variants, you can take either of two routes. The first one is to go through a Docker installation, and the second one is a Node.js direct installation. For Docker installation, repeat the volume and docker-compose commands. For a non-Docker installation, these are the instructions:

1. Installing Node.js and npm

n8n requires Node.js version 18 or later to run. LTS versions (like 18.x or 20.x) are more stable. Use NodeSource to install:

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

sudo apt install -y nodejs

Now, verify that the installation was successful by running the following commands:

node -v

npm -v

2. Installing n8n Globally

After installing Node.js, the following command will install n8n globally:

sudo npm install -g n8n

If you see a permission error, use sudo.

After installation, you can test the service by running n8n or n8n start:

n8n start

Now open the following address in your browser:

http://<your-server-ip>:5678

4. Create a dedicated user for n8n (a security suggestion)

Instead of running n8n as root, create a separate user:

sudo useradd -r -m -d /var/lib/n8n -s /bin/bash n8n

sudo chown -R n8n:n8n /var/lib/n8n

4. Configuring n8n with Environment Variables

You can use an .env file to set the domain, authentication, and URLs:

sudo nano /var/lib/n8n/.env

and enter these values:

N8N_BASIC_AUTH_ACTIVE=true

N8N_BASIC_AUTH_USER=admin

N8N_BASIC_AUTH_PASSWORD=strongpassword

N8N_PORT=5678

N8N_PROTOCOL=https

N8N_HOST=n8n.yourdomain.com

WEBHOOK_URL=https://n8n.yourdomain.com

5. Configure the systemd service to run n8n automatically

Create the following file:

sudo nano /etc/systemd/system/n8n.service

and enter the following content:

[Unit]

Description=n8n Automation Service

After=network.target

[Service]

Type=simple

User=n8n

EnvironmentFile=/var/lib/n8n/.env

ExecStart=/usr/bin/n8n

Restart=always

RestartSec=10

[Install]

WantedBy=multi-user.target

Enable and run the service:

sudo systemctl daemon-reload

sudo systemctl enable --now n8n

sudo systemctl status n8n

6. Configure Firewall

To allow access to port n8n:

sudo ufw allow 5678/tcp

sudo ufw reload

If you are only using HTTPS (with Nginx), you can keep port 5678 internal and open only 80 and 443.

7. Set up SSL and reverse proxy with Nginx

For secure access with HTTPS, set up Nginx as a reverse proxy:

sudo apt install -y nginx certbot python3-certbot-nginx

Create the following config file:

sudo nano /etc/nginx/sites-available/n8n

Content:

server {

listen 80;

server_name n8n.yourdomain.com;

return 301 https://$host$request_uri;

}

server {

listen 443 ssl http2;

server_name n8n.yourdomain.com;

ssl_certificate /etc/letsencrypt/live/n8n.yourdomain.com/fullchain.pem;

ssl_certificate_key /etc/letsencrypt/live/n8n.yourdomain.com/privkey.pem;

location / {

proxy_pass http://localhost:5678/;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection 'upgrade';

proxy_set_header Host $host;

proxy_cache_bypass $http_upgrade;

}

}

Activate the site and obtain the SSL certificate:

sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/

sudo nginx -t && sudo systemctl reload nginx

sudo certbot --nginx -d n8n.yourdomain.com

If the output contains the following message, SSL was successfully installed:

Congratulations! Your certificate and chain have been saved...

9. Backup and Update

Before any upgrade:

sudo cp -r /var/lib/n8n ~/.backup_n8n_$(date +%F)

To update n8n:

sudo npm install -g n8n@latest

sudo systemctl restart n8n

Now your n8n is permanently running on your Ubuntu server, with security, SSL, and automatic service management via systemd.

You can log in to the interface and create an administrator account by going to: https://n8n.yourdomain.com

to install n8n on Mac, you can use both Docker Desktop and a direct installation of Node.js. If you install Docker Desktop, the execution process is the same as on Linux, and you just need to run the docker run or docker-compose commands. In addition, you can install Node.js via Homebrew and install n8n via npm. For example:

brew install node         # Install Node.js with Homebrew

npm install -g n8n        # Install n8n globally

Then the command n8n start will run the program, and it can be accessed at http://localhost:5678. 

install n8n on mac os

The advantage of a local installation on Mac is that it is fast and does not require a virtual machine. However, this method is more suitable for development and testing, and is not recommended for production and hosting multiple users at the same time. However, for production on Mac, you can use Docker or a separate Linux server (e.g. VPS).

Verifying Docker and Node.js Installation

Verifying Docker and Node.js Installation

To ensure that Docker Desktop is successfully installed, check the Status Bar menu to make sure the service is running. You can also check with the following command:

docker --version

docker compose version

For Node.js, the following command will also display the versions:

node -v

npm -v

🔹 Create a permanent service (optional)

If you want n8n to run automatically in the background, you can use tools like pm2:

npm install -g pm2

pm2 start n8n

pm2 save

pm2 startup

This will make n8n run after a system restart.

You can install n8n on Windows either directly or with Docker. The three main methods are installing with Node.js, running a container via Docker Desktop, or using WSL2, each explained step by step below.

Method 1: Installing directly with Node.js and npm

Installing directly with Node.js and npm

First, go to the official Node.js website and download and install the LTS (long-term support) version. Then, follow these steps:

  1. After installation, open a PowerShell or CMD window and check the installation with the following commands:

node -v

npm -v

If the versions are displayed, Node.js and npm are installed correctly.

  1. Now install n8n globally:

npm install -g n8n

If you see a permission error (Permission Denied), open the PowerShell window with the Run as Administrator option.

  1. Runni n8n:

n8n start

Now n8n is running on port 5678, and you can open it in your browser: http://localhost:5678

📁 The n8n settings and data folder on Windows is created by default in this path: %USERPROFILE%\.n8n

Method 2: Installing and running n8n with Docker Desktop

The Docker method on Windows keeps the n8n environment isolated from your system and makes the installation easier.

  1. Install the Docker Desktop software from the official Docker website: https://www.docker.com/products/docker-desktop
  2. After installation, make sure that Docker is enabled in WSL2 backend mode (in Docker settings → General → “Use the WSL 2 based engine”).
  3. Now run the following command in PowerShell to temporarily run n8n:

docker run -it --rm --name n8n `

-p 5678:5678 `

-v n8n_data:/home/node/.n8n `

docker.n8n.io/n8nio/n8n

Then, in your browser, navigate to the following address: http://localhost:5678

For stable and continuous execution, use the docker-compose.yml file (in the same path as the project):

version: '3.7'

services:

n8n:

image: n8nio/n8n

ports:

"5678:5678"

environment:

N8N_BASIC_AUTH_ACTIVE=true

N8N_BASIC_AUTH_USER=admin

N8N_BASIC_AUTH_PASSWORD=strongpass

volumes:

n8n_data:/home/node/.n8n

volumes:

n8n_data:

Then run:

docker compose up -d

This will run n8n in the background and your data will be permanently stored in the volume.

Method 3: Using WSL2 (for advanced users)

If you are familiar with the Linux environment, it is better to use WSL2 to enjoy the benefits of both worlds (Windows and Linux):

Activating WSL2 on Windows:

wsl –install

  1. After installation, install the Ubuntu distribution from the Microsoft Store.
  2. Then open the Ubuntu terminal and follow the instructions in the “Installing n8n on Linux” section to install Node.js, npm, and n8n.

The advantage of WSL2 is that it eliminates many of the problems related to file paths and permissions on Windows, and the performance of n8n will be smoother.

Installing n8n on Windows is simple and can be done in a few minutes. However, for stable use and online hosting, Linux or Docker methods usually offer higher performance and security. In production environments, it is recommended to run n8n inside WSL2 or Docker Compose for easy backup, update, and management.

Installing n8n locally

For quick builds and local testing, you can install n8n locally using two main methods: npm and npx.

With npm

On any system (Linux, Mac, Windows) that has Node.js installed, just run:

npm install -g n8n

n8n

or

npm install -g n8n

n8n start

This command starts n8n, and after displaying the path, you can use its interface by going to http://localhost:5678. Make sure your Node.js version is 18 or higher.

With npx

If you don't want to install n8n, you can run it directly:

npx n8n

This method will download the necessary files and run the n8n application on a temporary basis. It is suitable for short-term testing.

How to install n8n community nodes

how to install n8n community nodes

 Some community-specific plugins or nodes (like n8n-nodes-nodeName) are installed via npm. If you need to add a new node, you can install it by going into the n8n folder (or inside a Docker container) and running:

npm i n8n-nodes-nodeName

Then restart n8n to make the new node available. To remove or update a node, use npm uninstall followed by npm install.

Note: A local installation is best for development environments and stores data on the same system. If you need data persistence, consider using Docker or installing on a server.

Before ending this post, take a quick look at the essential security and maintenance tips for keeping your n8n setup safe and reliable:

Topic

Technical Notes & Recommendations

Automatic Backups

Before every update, back up Docker volumes like n8n_data and database data:docker run --rm -v n8n_data:/data -v $(pwd):/backup busybox tar czf /backup/n8n_backup.tar.gz /data.For npm installs, export your SQLite or external database manually.

Updating n8n

For Docker: docker-compose pull && docker-compose up -d.For npm: npm update -g n8n. Always verify the service after upgrading.

Set N8N_HOST

Assign N8N_HOST to your domain or server IP (e.g., n8n.example.com) to ensure webhook URLs are generated correctly.

SSL Certificate (HTTPS)

Use Let’s Encrypt with Nginx for free SSL:sudo certbot --nginx -d n8n.example.com is also a simple alternative for automatic SSL setup.

Firewall Configuration

Open only essential ports:sudo ufw allow 5678,80,443/tcp. Always enable Basic Auth (N8N_BASIC_AUTH_ACTIVE=true) for public access.

Monitoring & Maintenance

Check logs regularly:Docker: docker logs n8n.npm: in ~/.n8n.Common issues involve permission or port conflicts — check N8N_PORT and file ownership if needed.

Keep these practices in mind to ensure your n8n instance runs smoothly for the long term.

In this guide, we have looked at the different ways to install n8n. Finally, if you are planning to run n8n on a robust and supported server, a Linux virtual server is a good option. With our Linux VPS services, you can run n8n on servers with 24/7 access and technical support. Our servers are located in over 40 global locations and have the lowest latency with 1Gbps ports. For more information and to get the right server, you can get a free consultation from us.

There are several ways to install it: you can use Docker or Docker Compose (with the docker run command or the docker-compose.yml file) or install it with npm (npm install -g n8n). For a quick test, the npx n8n command is also a great option and works without installation.

First, install Docker and create a volume for the data (docker volume create n8n_data). Then run the docker run command to start the n8n container on port 5678. Once it’s up and running, navigate to http://localhost:5678 in your browser to see the n8n web interface.

Make sure Node.js is installed, then type in the terminal: npm install -g n8n followed by n8n start. Open http://localhost:5678 in your browser to access the n8n environment. You can also use npx n8n for faster execution.

Yes, n8n is designed for self-hosting and can be run on a personal server, VPS, or cloud. The open-source version is completely free and has no limits on workflows or the number of workflow executions.

For local development or testing, install Node.js and install n8n with npm install -g n8n. Then run n8n or n8n start and log in from http://localhost:5678. This is fast and suitable for development, but for production,  it is better to use Docker.

Yes, n8n is completely free and open source under the Faircode license. There is no cost if you host it yourself, but the cloud version (n8n Cloud) offers paid plans for additional features and support.

Ethan Bennett

Ethan Bennett

An experienced tech and developer blog writer, specializing in VPS hosting and server technologies. Fueled by a passion for innovation, I break down complex technical concepts into digestible content, simplifying tech for everyone.