How to Install n8n on Ubuntu 23

This guide is meticulously tailored for beginners, aiming to demystify the process of setting up n8n on Ubuntu. Whether you’re venturing into automation for the first time or seeking to expand your toolkit, this guide will walk you through the essentials of deploying n8n on your VPS, step by step, ensuring a smooth and successful setup even without prior experience in the domain. Let’s start on this journey to unlock the full potential of workflow automation with n8n, paving the way for streamlined processes and enhanced productivity in your projects or organizational workflows.

What is n8n?

Before starting with the technicalities, let’s understand what n8n is. n8n (pronounced as “n-eight-n”) is an extendable workflow automation tool that simplifies the process of connecting different apps and services. Whether you’re looking to automate parts of your social media, handle complex data workflows, or even automate tasks across your personal projects, n8n provides a graphical interface to make these tasks easier and more intuitive.

Advantages of Installing n8n on Ubuntu 23:

Choosing to deploy n8n on an Ubuntu 23 VPS carries several significant benefits, especially for those looking to harness the full potential of automation:

  • Reliability and Uptime: With n8n running on a VPS, you can ensure that your automated workflows are always active, processing data, and performing tasks even when your local machine is off. This reliability is crucial for time-sensitive or continuous automation tasks.
  • Scalability: As your automation needs expand, a VPS can easily be scaled up to offer more resources, ensuring that your n8n setup continues to run smoothly without bottlenecks.
  • Control and Security: Installing n8n on your VPS gives you complete control over the environment and the data processed by your workflows. This aspect is particularly important for businesses or individuals with specific compliance or security requirements.
  • Customization: With direct access to the underlying system, you can customize your n8n instance to your heart’s content, optimizing it for performance, security, or specific functionalities.

Prerequisites

  1. A server with Root Access:
    • Ensure that your server is up and running. For this guide, we’ll assume you’re using a Linux distribution, with Ubuntu 23 being a popular and well-supported choice. Root access is important as it allows you to perform administrative tasks, including software installation and system configuration changes.
  2. Docker Installation:
    • Docker is a platform that enables you to easily deploy and manage applications in lightweight containers. Installing Docker on your server simplifies the process of setting up n8n, as n8n can run inside a Docker container. If Docker isn’t installed on your VPS yet, visit our Docker installation guide. Follow the instructions specific to your Linux distribution to ensure a smooth setup.
  3. Command Line and SSH Familiarity:
    • Basic knowledge of using the command line and SSH (Secure Shell) is essential. You’ll be using the command line to execute Docker commands, manage files, and perform other setup tasks. SSH allows you to securely connect to your VPS from your local machine, providing a command-line interface for remote administration.

Prepare the Docker Compose File

Docker Compose is a tool that helps manage multi-container Docker applications. With a single command, you can configure, run, and scale services defined in a docker-compose.yml file. For n8n, using Docker Compose allows you to easily manage the service and any additional components it might need, such as databases, in a straightforward and replicable manner.

Creating the Docker Compose File for n8n:

Navigate to Your Desired Directory: First, decide where you want to keep your docker-compose.yml file. It could be your home directory or a specific directory dedicated to n8n or Docker projects. For example, to create an n8n directory in your home folder, you can use:

mkdir ~/n8n && cd ~/n8n

Create the docker-compose.yml File: Using a text editor from the command line, such as nano or vim, create a new docker-compose.yml file:

nano docker-compose.yml

Add n8n Service Configuration: In the docker-compose.yml file, you will define the n8n service. Below is a basic example configuration for n8n, which sets up n8n to run on the default HTTP port (5678). Paste the following content into the file:

version: '3.1'

services:
  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=password
      - N8N_SECURE_COOKIE=false
Add n8n Service Configuration

This configuration does the following:

  • image: Specifies the Docker image to use for the service. n8nio/n8n is the official n8n Docker image.
  • restart: Configures the restart policy for the container. always ensures that the container restarts automatically if it crashes or if the server reboots.
  • ports: Maps port 5678 on the host to port 5678 inside the Docker container, allowing you to access n8n via http://localhost:5678 or http://<your-vps-ip>:5678.
  • environment: Sets environment variables to activate basic authentication and define the username and password. This is a basic security measure. Remember to change the username and password to something more secure.

Save and Close the File: If you’re using nano, save the changes by pressing Ctrl + O, then Enter, and exit with Ctrl + X. If you’re using vim, save and exit by typing :wq and then pressing Enter.

After creating your docker-compose.yml file with the n8n service defined, you’re ready to launch n8n using Docker Compose. This setup not only makes starting and stopping n8n simpler but also makes your n8n deployment easily reproducible and portable.

Launching n8n on Ubuntu Using Docker Compose

Run Docker Compose: To start n8n in detached mode (which means it will run in the background), execute the following command:

docker-compose up -d
Launching n8n on Ubuntu Using Docker Compose
  • What Happens Next? Docker Compose will read the docker-compose.yml file, pull the n8n Docker image from Docker Hub if it’s not already on your system, and then create and start the n8n container based on the specifications you provided. The -d flag ensures that the container runs in the background, allowing you to continue using the terminal for other tasks.

Verify n8n is Running: To confirm that the n8n container is up and running, you can use the command:

docker-compose ps
Verify if n8n on Ubuntu is Running

This command lists all containers managed by Docker Compose in the current directory, showing their status. You should see your n8n container listed as “Up”.

Accessing n8n:

With n8n now running, you can access the n8n Web UI by navigating to http://localhost:5678 if you’re working directly on your VPS via a graphical interface or http://<your-vps-ip>:5678 from any web browser, where <your-vps-ip> is the public IP address of your VPS.

n8n on Ubuntu Web UI

Congratulations! You’ve successfully launched your n8n instance using Docker Compose. This powerful tool is now ready to help you automate workflows between various applications and services. As you become more familiar with n8n, consider exploring more advanced configurations, such as integrating external databases or customizing your n8n setup to suit your specific needs.