Independent testing Updated April 2026 387 self-hosting guides 5 VPS providers tested

guide

How to Self-Host n8n on a VPS (Complete Guide)

Learn how to self-host n8n on a VPS with a complete step-by-step 2026 guide covering installation, configuration, and securing n8n for reliable daily use.

How to Self-Host n8n on a VPS (Complete Guide)

In todayโ€™s world, automation is key to improving productivity, and n8n is an excellent open-source workflow automation tool that lets you connect different apps and services without needing to write code. Self-hosting n8n on a Virtual Private Server (VPS) is a good option for developers looking for control and customization of their data flows. This guide covers the steps to install and configure n8n using Docker on a VPS.

Prerequisites

  1. Choose a VPS Provider: Select a VPS provider that fits your needs. Hereโ€™s a comparison of some popular options:
ProviderPrice (per month)RAMStorage
Contabo VPS5.99 EUR4 GB200 GB SSD
Hetzner Cloud4.15 EUR2 GB20 GB SSD
DigitalOcean6 USD1 GB25 GB SSD
Vultr6 USD1 GB25 GB SSD
Linode (Akamai)5 USD2 GB50 GB SSD
  1. Install Docker: Ensure that Docker and Docker Compose are installed on your VPS. If they are not installed, you can follow the official Docker installation guide.

  2. Secure Your Server: A basic firewall configuration with ufw (Uncomplicated Firewall) is recommended. This should include allowing SSH and the necessary ports for n8n.

Step 1: Set Up Docker

After logging in to your VPS via SSH, verify that Docker is installed by running:

docker --version

If Docker is not installed, you can install it using:

sudo apt update
sudo apt install docker.io

Enable and start Docker:

sudo systemctl enable docker
sudo systemctl start docker

Step 2: Create n8n Directory

Create a directory for n8n and navigate into it:

mkdir ~/n8n
cd ~/n8n

Step 3: Create Docker Compose File

Create a new docker-compose.yml file with your preferred text editor:

nano docker-compose.yml

Add the following configuration:

version: '3'
services:
  n8n:
    image: n8nio/n8n
    environment:
      - N8N_API_BASIC_AUTH_ACTIVE=true
      - N8N_API_BASIC_AUTH_USER=user
      - N8N_API_BASIC_AUTH_PASSWORD=your_password
      - N8N_HOST=your_domain_or_ip
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - N8N_SSL_CERT=your_ssl_cert_path
      - N8N_SSL_KEY=your_ssl_key_path
    volumes:
      - ~/.n8n:/home/node/.n8n
    ports:
      - "5678:5678"
    restart: always

Replace your_domain_or_ip, your_ssl_cert_path, and your_ssl_key_path with your information. You can use Letโ€™s Encrypt for SSL (more on this later).

Step 4: Run n8n

Start n8n using Docker Compose:

docker-compose up -d

Verify that n8n is running by checking if the container is active:

docker ps

Step 5: Access n8n

You can access your n8n instance using your VPS IP or domain name:

http://your_domain_or_ip:5678

Log in with the credentials you specified in the docker-compose.yml.

For enhanced security, it is a good practice to set up SSL. You can use Letโ€™s Encrypt:

  1. Install Certbot:

    sudo apt install certbot
  2. Get Certificates:

    sudo certbot certonly --standalone -d your_domain.com
  3. Update the docker-compose.yml file to include the correct SSL certificate paths as shown in Step 3.

After updating, restart the n8n services:

docker-compose down
docker-compose up -d

FAQs

1. What are the benefits of self-hosting n8n over using the cloud version?

Self-hosting n8n offers numerous benefits, including complete data control, customizable features according to specific needs, and more flexible automation possibilities by connecting with other self-hosted services. You can ensure that sensitive data remains private and comply with data protection regulations as you dictate how and where the data is processed. Ultimately, self-hosting also allows for experimenting with more integrations without potential usage limits typically imposed on cloud versions.

2. Can I run n8n on a low-tier VPS?

Yes, n8n can run on low-tier VPS, but performance may vary based on the complexity of the workflows you plan to execute. For simple automations, options like Hetzner Cloud or DigitalOcean with at least 1-2 GB of RAM should suffice. However, for heavier workflows that require storing larger data sets or running many simultaneous executions, you may need a more robust VPS setup, possibly with additional RAM and CPU.

3. How to backup n8n configurations and data?

Backing up n8n configurations and data is vital for ensuring the continuity of your workflows. Since n8n stores its data in the volume you mounted (as specified in the docker-compose.yml), you should regularly back up the ~/.n8n directory. This can be achieved by copying it to another location, scheduled via cron jobs, or by using backup services. Automating backups of this directory to cloud storage or another physical server aids in minimizing data loss and maintaining system resilience.

By following this complete guide, you will be well-prepared to self-host n8n on your VPS, tapping into its potential for automating workflows effectively. For comparisons of the best VPS providers, visit our full VPS comparison. Happy self-hosting!