How to Self-Host n8n on a VPS with Docker Compose (Step by Step)

Self-hosting n8n means running it on your own server instead of paying for n8n Cloud. This tutorial shows how to install n8n on a Linux VPS with Docker Compose, connect your own domain with HTTPS, keep your data safe, and update it later.

How to self-host n8n on a VPS with Docker Compose: domain, Traefik HTTPS, n8n container and data volume - Learnan Light tutorial

To self-host n8n you rent a small Linux server (a VPS), install Docker, and run n8n in a container behind a proxy that gives you HTTPS. The steps below follow n8n's own Docker Compose guide, checked on November 6, 2026. n8n says you need some server experience for this. If that is new to you, n8n Cloud is the easier route. Commands and file contents can change, so check n8n's page for the latest.

The short answer

  • What you need: a Linux VPS, a domain name you control, and Docker Engine with Docker Compose
  • What you install: n8n (n8nio/n8n) and Traefik, which handles HTTPS certificates
  • Main command: sudo docker compose up -d
  • Most important file to protect: the n8n_data volume, which holds your database and encryption key
  • Update with: docker compose pull, docker compose down, then docker compose up -d

Should You Self-Host n8n?

Self-hosting avoids n8n Cloud plan fees, but you become the person who runs the server. You handle updates, backups and fixes. It is a good fit if you are comfortable with a terminal, or want to learn. Not sure about costs? Read our guide on n8n pricing. n8n also notes that its free Community Edition leaves out some features that are paid-only.

What You Need Before You Start

  1. A Linux VPS from any provider. n8n's page does not give minimum RAM or CPU, so check your provider and n8n's docs
  2. A domain name you control, so n8n can run on an address like n8n.yoursite.com
  3. Docker Engine and Docker Compose installed. Check with docker --version and docker compose version
  4. An email address for your HTTPS certificate

Step 1: Point Your Domain to the Server

In your domain's DNS settings, create an A record for a subdomain, such as n8n, that points to your server's IP address. DNS can take a little time to update.

Step 2: Create a Project Folder

Connect to your server and run:

mkdir n8n-compose

cd n8n-compose

Step 3: Create the .env File

Create a file named .env in that folder with these four settings:

What to put in .env

  • DOMAIN_NAME: your main domain, for example example.com
  • SUBDOMAIN: for example n8n, so n8n opens at https://n8n.example.com
  • GENERIC_TIMEZONE: your timezone, for example Europe/Berlin. n8n says New York is the default if you do not set it
  • SSL_EMAIL: your email, used to create the HTTPS certificate

The timezone matters for schedule-based workflows, because it controls when a Schedule Trigger runs.

Step 4: Create a Shared Files Folder

Run mkdir local-files. This folder is shared between your server and n8n. Inside n8n, you use the path /files to reach it.

Step 5: Create the compose.yaml File

Create a file named compose.yaml. n8n's guide uses two services: Traefik, which manages HTTPS certificates and routing and listens on ports 80 and 443, and n8n, using the image n8nio/n8n.

Copy the full file from n8n's own Docker Compose page (linked in the sources below), because it contains exact labels and flags that must not be retyped by hand. These are the n8n settings to look for:

Key n8n settings in the file

  • N8N_HOST: your subdomain and domain
  • N8N_PROTOCOL: https
  • NODE_ENV: production
  • N8N_WEBHOOK_URL: https:// plus your subdomain and domain and a final / (on versions before 2.30.0, n8n says to use WEBHOOK_URL)
  • GENERIC_TIMEZONE and TZ: your timezone from the .env file
  • Volumes: n8n_data for the database and encryption key, and ./local-files for shared files

Step 6: Start n8n

Run:

sudo docker compose up -d

To stop it later, run sudo docker compose stop.

Step 7: Open n8n in Your Browser

Go to your subdomain, for example https://n8n.example.com. n8n says it is reachable over HTTPS only, not plain HTTP. If the page does not open, check your DNS record and your server's firewall.

How to Update n8n

n8n's documentation gives these Docker Compose update steps:

  1. Go to the folder that contains your compose file
  2. Run docker compose pull to download the latest version
  3. Run docker compose down to stop and remove the old container
  4. Run docker compose up -d to start the new one

n8n says to use the stable version for production, and that beta can be unstable. Your data stays in the n8n_data volume, so do not delete that volume. Do not add the -v option to docker compose down, because it can remove volumes.

Back Up Your Data

The n8n_data volume holds your workflows, credentials and the encryption key. If you lose the encryption key, saved credentials cannot be read. Make regular backups of this volume and keep a copy away from the server. Before each update, take a backup first.

Common Problems and Fixes

  • The page does not open: check that your A record points to the right IP and that ports 80 and 443 are open in the firewall
  • Webhooks from other apps fail: check that N8N_WEBHOOK_URL is your real HTTPS address, with the final slash
  • Schedules run at the wrong hour: check GENERIC_TIMEZONE and TZ
  • No HTTPS certificate: check the SSL email, and that your domain already points to the server

After You Self-Host: What to Build

Once n8n runs, build your first automation with our n8n beginners tutorial. You can also add AI to your workflows with ideas from our Claude Skills tutorial.

Frequently Asked Questions

How do I self-host n8n?

Rent a Linux VPS, install Docker and Docker Compose, point a domain to the server, create a .env and compose.yaml file, then run docker compose up -d. n8n's Docker Compose guide gives the steps.

What do I need to self-host n8n?

A Linux server, a domain name you control, Docker Engine with Docker Compose, and an email address for the HTTPS certificate.

Is self-hosting n8n free?

The Community Edition has no license fee, but you pay for your own server and your time. Some features are paid-only.

How do I update self-hosted n8n?

With Docker Compose, go to your compose folder and run docker compose pull, then docker compose down, then docker compose up -d. Back up your data first.

Where does n8n store my data?

By default in a SQLite database inside the n8n_data volume, which also holds the encryption key. Back this volume up.

Why do my n8n webhooks not work?

Check that the webhook URL setting is your real HTTPS address, and that your domain, firewall and certificate work.

Do I need a domain name to self-host n8n?

n8n's Docker Compose guide uses a domain so Traefik can create an HTTPS certificate. Other setups exist, but this is the one this tutorial follows.

From the Learnan Light shop

Recommended for this topic

Two Learnan Light products that go with this guide. Delivered by Gumroad.