How to Install n8n on Ubuntu (Step-by-Step Guide)

If you want to automate repetitive tasks, connect different applications, or build workflows without writing an entire application from scratch, n8n is worth exploring. In this tutorial, I will show you how to install n8n on Ubuntu Linux using Docker.

We will also learn how to access the n8n web interface, create our first workflow, manage the installation, and troubleshoot common issues. Additionally, I will cover some essential security practices that I recommend following before using n8n for important automation tasks.

For this tutorial, we will use Docker because it allows us to run n8n in a container without installing its application dependencies directly on Ubuntu.

Table of Contents
  1. What Is n8n?
  2. Prerequisites
  3. Method 1: Install n8n on Ubuntu Using the Official Setup Script
    1. Step 1: Update Ubuntu
    2. Step 2: Install Docker on Ubuntu
    3. Step 3: Install n8n Using the Official Setup Script
    4. Step 4: Access the n8n Web Interface
    5. Step 5: Create Our First Workflow
    6. Step 6: Manage the n8n Installation
  4. Method 2: Install n8n on Ubuntu Using Docker Compose Manually
    1. Step 1: Create a Directory for n8n
    2. Step 2: Generate an Encryption Key
    3. Step 3: Create the Docker Compose File
    4. Step 4: Start n8n
    5. Step 5: Open the n8n Interface
    6. Step 6: Manage the Manual Installation
  5. Essential Security and Backup Tips
  6. Troubleshooting Common n8n Installation Issues
    1. 1. Docker Compose Is Not Installed
    2. 2. The n8n Web Interface Does Not Open
    3. 3. The Container Keeps Restarting
    4. 4. Workflows or Credentials Are Missing
  7. Conclusion

What Is n8n?

n8n is a workflow automation platform that allows us to connect different applications, APIs, databases, and services to automate repetitive tasks. It provides a visual workflow editor where we can connect nodes and define how data moves between different services.

For example, we can use n8n to automate notifications, process form submissions, synchronize data between applications, or create workflows that interact with APIs.

One of the main advantages of n8n is that we can self-host it on our own Ubuntu computer or server. This gives us greater control over our deployment environment, configuration, and data.

However, self-hosting also means that we are responsible for maintaining the server, protecting sensitive credentials, installing updates, and backing up important data.

Prerequisites

Before we begin installing n8n on Ubuntu, let’s make sure our system meets the following requirements:

  • Operating system: Ubuntu 22.04 LTS, Ubuntu 24.04 LTS, or another supported Ubuntu release.
  • RAM: Enough memory for the workflows and other services we plan to run.
  • Processor: A compatible 64-bit processor.
  • Software: Docker Engine and Docker Compose v2.
  • Internet connection: Required to download Docker images and connect to external services.
  • Permissions: A user account with sudo privileges.

For a basic test installation, modest hardware may be sufficient. If we plan to run n8n on a production server, we should check that the server has sufficient memory, CPU, and storage for the expected workload.

Method 1: Install n8n on Ubuntu Using the Official Setup Script

For a fresh installation, I recommend starting with the official n8n setup script. It automates much of the initial configuration, making it a convenient option for beginners.

Step 1: Update Ubuntu

First, let’s connect to our Ubuntu server using SSH. If we are working directly on an Ubuntu desktop, we can open the Terminal instead.

Now, let’s update the package index and install the available package updates by running:

sudo apt update
sudo apt upgrade -y

The first command refreshes the package information, while the second installs available updates.

Once the update process finishes, we can move on to installing Docker.

Step 2: Install Docker on Ubuntu

Before we install n8n, we need Docker Engine and Docker Compose. The official n8n setup script relies on Docker to run n8n and its supporting services.

If Docker is not already installed on our system, you can follow my separate tutorial on How to Install Docker on Ubuntu.

In that guide, I explained two installation methods. For this setup, I recommend Method 2: Install Docker from the Official Docker Repository, which installs Docker Engine along with the Docker Compose plugin.

After completing the Docker installation, let’s return to our terminal and verify that both commands work:

sudo docker --version
sudo docker compose version

If both commands display their respective version information, we are ready to continue.

If Docker is already installed, we can skip the installation tutorial and proceed directly to the next step.

Step 3: Install n8n Using the Official Setup Script

Now that Docker is ready, let’s install n8n using its official setup script.

Run the following command in our terminal:

curl -fsSL https://get.n8n.io | sh

This command downloads and executes the n8n setup script. The script checks for Docker and Docker Compose, creates a directory named n8n in our current working directory, generates the required configuration files and secrets, downloads the necessary images, and starts the services.

The first installation may take a few minutes because Docker needs to download the required images.

Important: The command executes a remote shell script. If we want to inspect it before running it, we can download the script first and review its contents.

Once the installation finishes, the script should display the address where n8n is available and the location of its configuration files.

Step 4: Access the n8n Web Interface

Now let’s open a web browser and access our n8n installation.

If we installed n8n on our local Ubuntu computer, open:

http://localhost:5678

If we installed it on a remote Ubuntu server, we may be able to access it using the server’s IP address and port 5678:

http://SERVER_IP:5678

Replace SERVER_IP with the actual IP address of our server. Remote access also depends on the server’s network and firewall configuration.

When the page loads, follow the on-screen instructions to create the initial owner account and complete the setup.

Security note: We should not expose an n8n login page over an unencrypted HTTP connection on a public network. For remote or production access, configure HTTPS using a domain name and a reverse proxy, and restrict access to the instance.

Step 5: Create Our First Workflow

Now that n8n is running, let’s create a simple workflow to confirm that everything works.

  1. Sign in to the n8n web interface.
  2. Create a new workflow.
  3. Add a Manual Trigger node.
  4. Add an Edit Fields (Set) node and connect it to the trigger.
  5. In the Edit Fields node, add a field named message and set its value to Hello from n8n on Ubuntu.
  6. Save the workflow and execute it manually.
  7. Open the execution results and check whether the output contains our message field.

If we can see the expected output, our first workflow is working.

We can now expand this workflow by connecting additional nodes, such as an HTTP Request node, a database node, or an email integration. Some integrations require us to configure credentials before they can run.

Step 6: Manage the n8n Installation

The official setup script creates the configuration files inside the n8n directory from which we ran it. Let’s move into that directory:

cd n8n

We can use Docker Compose to manage the running services.

To check their status, run:

sudo docker compose ps

To view the service logs, run:

sudo docker compose logs -f

Press Ctrl+C to stop following the logs. This does not stop the services.

To stop the services, run:

sudo docker compose down

To start them again, run:

sudo docker compose up -d

To upgrade an installation created by the current official setup script, return to the same directory and use the documented upgrade command:

curl -fsSL https://get.n8n.io | sh -s -- --upgrade

Before upgrading an installation that contains important workflows or credentials, we should take a backup and review the current official upgrade instructions.

Note: The official setup script manages its own configuration and supporting services. We should not mix its management commands with those of a separately created Docker Compose installation.

Method 2: Install n8n on Ubuntu Using Docker Compose Manually

If we want more direct control over the configuration, we can create our own Docker Compose file. This approach is useful when we want to manage environment variables and persistent storage ourselves.

If we completed Method 1, we should not follow this method on top of that installation. Instead, use it as an alternative for a fresh installation.

Step 1: Create a Directory for n8n

Let’s create a separate directory for our manual installation:

mkdir -p ~/n8n-compose
cd ~/n8n-compose

This directory will contain our Docker Compose configuration.

Step 2: Generate an Encryption Key

n8n uses an encryption key to protect stored credentials. Let’s generate a strong key before configuring the service:

openssl rand -hex 32

Copy the generated value and keep it somewhere secure. We will use it in the next step.

Do not publish this key or share it with anyone. If we change the key later without following the appropriate migration procedure, existing encrypted credentials may become inaccessible.

Step 3: Create the Docker Compose File

Let’s create a new Compose file using the Nano text editor:

sudo nano compose.yaml

Add the following configuration:

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: unless-stopped
    ports:
      - "127.0.0.1:5678:5678"
    environment:
      - GENERIC_TIMEZONE=Asia/Kolkata
      - TZ=Asia/Kolkata
      - N8N_ENCRYPTION_KEY=REPLACE_WITH_YOUR_GENERATED_KEY
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

Before saving the file, replace REPLACE_WITH_YOUR_GENERATED_KEY with the key we generated in the previous step.

The configuration uses a persistent Docker volume named n8n_data to store n8n’s application data. It also sets the timezone to India Standard Time.

Notice that port 5678 is bound to 127.0.0.1. This means n8n is accessible only from the server itself, which is a safer starting point for a server deployment. We can later configure a reverse proxy with HTTPS for remote access.

In Nano, press Ctrl+O, then Enter to save the file, and Ctrl+X to exit.

Step 4: Start n8n

Now let’s validate the Compose configuration and start the service:

sudo docker compose config
sudo docker compose up -d

The first command checks the configuration, while the second downloads the image if necessary and starts n8n in the background.

Let’s check the container status:

sudo docker compose ps

If the container is running, we can check its logs if needed:

sudo docker compose logs -f n8n

Press Ctrl+C when we are finished viewing the logs.

Step 5: Open the n8n Interface

Because we bound port 5678 to localhost, we cannot access this installation directly through the server’s public IP address.

If n8n is running on a remote server, we can create an SSH tunnel from our local computer:

ssh -L 5678:127.0.0.1:5678 USER@SERVER_IP

Replace USER with our SSH username and SERVER_IP with the server’s IP address.

Keep the SSH session open, then visit the following address in our local browser:

http://localhost:5678

We should now see the n8n setup page. Follow the on-screen instructions to create the owner account.

For a long-running deployment, we should configure a domain name and HTTPS reverse proxy instead of relying on an SSH tunnel.

Step 6: Manage the Manual Installation

Let’s review the commands we can use to manage our manually configured installation.

Check the status:

sudo docker compose ps

View the logs:

sudo docker compose logs -f n8n

Restart the service:

sudo docker compose restart n8n

Stop the service:

sudo docker compose down

Start it again:

sudo docker compose up -d

To update the n8n image, we can first take a backup, then pull the newer image and recreate the container:

sudo docker compose pull
sudo docker compose up -d

After updating, let’s verify the service status and review the logs. We should also check the release notes for any required configuration or migration changes before upgrading a production instance.

Essential Security and Backup Tips

Before we use n8n for important automation tasks, let’s review a few precautions.

  • Use HTTPS for remote access. Configure a domain name and a reverse proxy with a valid TLS certificate before exposing the interface over the internet.
  • Protect credentials and secrets. Keep the encryption key, configuration files, API tokens, and passwords private.
  • Keep n8n updated. Review release notes and apply updates after backing up important data.
  • Back up persistent data. The database, configuration, and encryption key are important. A backup should include the data stored in the n8n volume and the relevant configuration files.
  • Restrict access. Avoid exposing port 5678 publicly without appropriate access controls.
  • Review workflows and community nodes.** Only install trusted community nodes and be careful with workflows that execute code or access sensitive systems.

For the manual Compose installation, we can create a backup of the Docker volume while n8n is stopped. First, stop the service:

sudo docker compose down

Then create a compressed archive of the volume:

sudo docker run --rm -v n8n_data:/data:ro -v "$PWD":/backup alpine tar -czf /backup/n8n-data-backup.tar.gz -C /data .

This creates n8n-data-backup.tar.gz in our current directory. We should also securely back up compose.yaml and preserve the encryption key separately. Store backups somewhere other than the same server whenever possible.

After completing the backup, let’s start n8n again:

sudo docker compose up -d

The backup procedure above is for the manually configured Compose installation. If we used Method 1, we should first identify and back up the actual volume and configuration created by the official setup script rather than assuming it uses the same volume name.

Troubleshooting Common n8n Installation Issues

1. Docker Compose Is Not Installed

If we see an error stating that the docker compose command is unavailable, let’s verify the Docker installation:

sudo docker --version
sudo docker compose version

If the Compose plugin is missing, follow the official Docker repository installation method in my tutorial Docker installation tutorial for Ubuntu

2. The n8n Web Interface Does Not Open

First, let’s check whether the service is running:

sudo docker compose ps

Next, let’s review the logs:

sudo docker compose logs --tail=100 n8n

If we used Method 1, run the commands from the n8n directory and omit n8n from the final command if we need logs from all services.

We should also verify the URL, port mapping, firewall rules, and whether the service has finished starting.

3. The Container Keeps Restarting

Let’s inspect the logs for configuration errors, permission issues, or other startup failures:

sudo docker compose logs --tail=100 n8n

If we recently edited the Compose file, let’s verify the syntax and ensure that the encryption key and other environment variables are valid.

4. Workflows or Credentials Are Missing

First, let’s confirm that the installation is using its intended persistent storage. If we accidentally created a new volume or started the service from a different Compose configuration, n8n may appear to have no previous data.

Do not remove Docker volumes while troubleshooting. Deleting a volume can permanently remove workflows, credentials, and other application data.

Conclusion

In this tutorial, we installed n8n on Ubuntu using Docker. We also learned how to access the web interface, create a basic workflow, manage the services, and apply essential security and backup practices.

For a straightforward fresh installation, the official setup script is a convenient choice. If we need more control over the configuration, a manual Docker Compose deployment is a useful alternative.

Now that n8n is running, we can start connecting our applications and building workflows to automate repetitive tasks.

Frequently asked questions

Is n8n free to install on Ubuntu?

Yes. We can self-host the n8n Community edition on our own infrastructure without purchasing a paid n8n license. However, server hosting, domain registration, external APIs, and third-party services may incur costs.

Can I run n8n without Docker?

n8n has offered other installation approaches, but its current documentation recommends using Docker-based deployment options for new installations. The official one-line setup script uses Docker and Docker Compose.

Does n8n keep my workflows after a restart?

Yes, provided the installation uses persistent storage and that storage is not deleted. We should still create regular backups to protect against data loss.

Can I access n8n from another computer?

Yes. For a local installation, we can access n8n from the same computer. For a remote server, we can use an SSH tunnel or configure a domain name and HTTPS reverse proxy. We should avoid exposing the login interface over unencrypted HTTP on a public network.

Share this...

Sourabh Verma

Hi, I'm Sourabh Verma, an IT professional with 12+ years of experience. At BeginnersBox, I share practical, well-tested how-to guides on Windows, Linux, WordPress, web hosting, and other tech topics. My goal is to provide simple, reliable solutions that actually work. Hope you like my work. Thanks