How to self-host n8n on your own server
About 30 minutes · Commands checked against the official documentation on November 19, 2026
n8n is an open-source workflow automation platform. Self-hosting it keeps your workflows, credentials and execution history on a server you control, with no per-execution pricing.
This guide follows n8n's own Docker Compose setup. You end with n8n at an address like https://n8n.yourdomain.com, with HTTPS certificates issued and renewed automatically.
n8n is #1 on the all-time Top 100 this week.
You will need
- A 64-bit Linux server running Ubuntu 24.04 LTS
- A domain name where you can add DNS records
- Comfort with SSH and a terminal
n8n's documentation says self-hosting is for experienced users: mistakes can cause data loss, security issues and downtime. If you have never run a server, n8n Cloud is the safer choice.
1.Get a server
Rent a virtual private server (VPS) running Ubuntu 24.04 LTS. n8n's documentation doesn't set a minimum size for this setup. For personal use, a server with 2 GB of memory is a comfortable start, and you can resize it later.
Any provider works. When it is created you will have an IP address and a way to log in over SSH, usually as root or as a user that can run sudo.
2.Point a subdomain at the server
In your domain's DNS settings, add an A record so that a subdomain (for example n8n.yourdomain.com) points at the server's IP address:
Type: A Name: n8n Value: <your server's IP address>DNS changes can take a few minutes to reach everyone. The certificate in step 7 is only issued once this record resolves.
3.Install Docker
Log in to the server over SSH, then install Docker Engine and the Compose plugin from Docker's official repository:
# Add Docker's official GPG key: sudo apt update sudo apt install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc # Add the repository to Apt sources: sudo tee /etc/apt/sources.list.d/docker.sources <<EOF Types: deb URIs: https://download.docker.com/linux/ubuntu Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") Components: stable Architectures: $(dpkg --print-architecture) Signed-By: /etc/apt/keyrings/docker.asc EOF sudo apt update # Install Docker: sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginCheck that both are available. If Docker isn't running, start it with sudo systemctl start docker.
4.Check Docker, and optionally run it without sudo
docker --version docker compose versionOptional: to run Docker without typing sudo every time, add your user to the docker group:
sudo usermod -aG docker ${USER} exec sg docker newgrp5.Create the project folder and settings file
mkdir n8n-compose cd n8n-composeInside that folder, create a file called .env with the contents below, changed to your own domain, subdomain, timezone and email address. The email is used for the HTTPS certificate.
# DOMAIN_NAME and SUBDOMAIN together determine where n8n will be reachable from # The top level domain to serve from DOMAIN_NAME=example.com # The subdomain to serve from SUBDOMAIN=n8n # The above example serve n8n at: https://n8n.example.com # Optional timezone to set which gets used by Cron and other scheduling nodes # New York is the default value if not set GENERIC_TIMEZONE=Europe/Berlin # The email address to use for the TLS/SSL certificate creation SSL_EMAIL=user@example.com6.Create the files folder and the Compose file
Create a folder n8n can read and write files in:
mkdir local-filesThen create a file called compose.yaml in the same folder, containing n8n's official configuration below. It runs n8n behind Traefik, a proxy that obtains and renews the HTTPS certificate.
services: traefik: image: "traefik" restart: always command: - "--api.insecure=true" - "--providers.docker=true" - "--providers.docker.exposedbydefault=false" - "--entrypoints.web.address=:80" - "--entrypoints.web.http.redirections.entryPoint.to=websecure" - "--entrypoints.web.http.redirections.entrypoint.scheme=https" - "--entrypoints.websecure.address=:443" - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true" - "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}" - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json" ports: - "80:80" - "443:443" volumes: - traefik_data:/letsencrypt - /var/run/docker.sock:/var/run/docker.sock:ro n8n: image: n8nio/n8n restart: always ports: - "127.0.0.1:5678:5678" labels: - traefik.enable=true - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`) - traefik.http.routers.n8n.tls=true - traefik.http.routers.n8n.entrypoints=web,websecure - traefik.http.routers.n8n.tls.certresolver=mytlschallenge - traefik.http.middlewares.n8n.headers.SSLRedirect=true - traefik.http.middlewares.n8n.headers.STSSeconds=315360000 - traefik.http.middlewares.n8n.headers.browserXSSFilter=true - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true - traefik.http.middlewares.n8n.headers.forceSTSHeader=true - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME} - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true - traefik.http.middlewares.n8n.headers.STSPreload=true - traefik.http.routers.n8n.middlewares=n8n@docker environment: - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME} - N8N_PORT=5678 - N8N_PROTOCOL=https - NODE_ENV=production - N8N_WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/ - GENERIC_TIMEZONE=${GENERIC_TIMEZONE} - TZ=${GENERIC_TIMEZONE} - N8N_RESTRICT_FILE_ACCESS_TO=/files volumes: - n8n_data:/home/node/.n8n - ./local-files:/files volumes: n8n_data: traefik_data:7.Start n8n
sudo docker compose up -dOpen https://n8n.yourdomain.com (your subdomain and domain) and create the owner account straight away. n8n is only served over HTTPS.
If the page doesn't load, check that the DNS record from step 2 resolves and that ports 80 and 443 are open in the server's firewall.
To stop n8n: sudo docker compose stop
Updating
n8n releases a new minor version most weeks. Follow the Docker Compose section of n8n's update guide, linked below, and back up first.
Backups
Your workflows, the SQLite database and n8n's encryption key are stored in the n8n_data Docker volume. Back it up. Without the encryption key, saved credentials can't be decrypted.
When to change this setup
This setup uses n8n's built-in SQLite database, which n8n describes as suited to testing and small setups. For multi-user production use, n8n recommends PostgreSQL. See its production requirements page.
Sources
Every command above is taken from these pages. If a step has changed, they are the authority.