Guide · Workflow automation

How to self-host n8n on your own server

Follow 23 steps in 5 parts: plan the server, install n8n with Docker or in one click, put it behind your own domain with HTTPS, then secure it, back it up and keep it updated. Every command is ready to copy.

By the VPSPulse team · Updated · 17 min read

  • Docker and PostgreSQL
  • HTTPS with Caddy or Nginx
  • Commands for Ubuntu

How do you self-host n8n?

To self-host n8n, you need a Linux server that stays online, with at least 1 GB of RAM for testing and 2 GB or more for real work. Install Docker, run n8n's official image with a volume for its data, and for production switch to Docker Compose with PostgreSQL, the database n8n recommends. Put a reverse proxy such as Caddy or Nginx in front for HTTPS, tell n8n its public webhook address, create the owner account, then lock the server down and back it up. By hand that takes most people under an hour. On a VPSPulse server, n8n is installed for you in one click.

At a glance

Time
30 to 60 minutes by hand, a few minutes with one-click install
Skill level
Comfortable with SSH and a terminal
You need
A Linux server, a domain name, SSH access
Default port
5678
Database
SQLite by default, PostgreSQL for production
Jump to a section
  1. Part 1: Plan your n8n server
    1. Before you start
    2. What self-hosting n8n means, and when n8n Cloud fits better
    3. How much server does n8n need?
  2. Part 2: Install n8n
    1. Option A: install n8n in one click on VPSPulse
    2. Option B: install n8n manually with Docker
    3. Install Docker Engine
    4. Try n8n with one command
    5. Write a Docker Compose file with PostgreSQL
    6. Start n8n and watch the logs
    7. The settings that matter
  3. Part 3: Domain, HTTPS and first login
    1. Point your domain at the server
    2. Add Caddy as the reverse proxy
    3. Prefer Nginx? Same idea, a few more lines
    4. Check that n8n knows its address
    5. Create the owner account and test a webhook
  4. Part 4: Secure, back up and update n8n
    1. Open only the ports you need
    2. Work through the security checklist
    3. What to back up
    4. Export workflows and credentials with the n8n CLI
    5. Dump the PostgreSQL database
    6. Update n8n safely
  5. Part 5: Move your workflows and fix problems
    1. Move your workflows from n8n Cloud
    2. Troubleshooting common problems
  6. FAQ

Part 1: Plan your n8n server

Before you type a command, get the basics ready, decide whether self-hosting suits you and pick a server size.

Step 1

Before you start

Get these five things ready and the rest of the guide goes quickly.

  • A Linux server that stays online. The commands here are for Ubuntu; any current LTS release works. A plain Ubuntu VPS is a good base.
  • Root or sudo access over SSH. If that is new to you, our guide on how to set up a VPS covers connecting, updating and the first security steps.
  • A domain or subdomain you can point at the server, such as n8n.your-domain.com. You need it for HTTPS and for webhook URLs other services can call.
  • Enough memory. 1 GB is fine to learn on; plan on 2 GB or more for workflows you depend on. Sizing is covered below.
  • Somewhere to keep backups that is not the server itself: your own computer, object storage or a second server.

Good to know: n8n is fair-code software under the Sustainable Use License. The Community Edition is free to self-host when the people building workflows are in your own organization. If you want to offer n8n to others as a service or white-label it, n8n asks for its commercial license.

Step 2

What self-hosting n8n means, and when n8n Cloud fits better

n8n is a workflow automation tool. Something happens, such as a webhook call, a schedule or a new row in a sheet, and n8n passes the data through a chain of nodes that talk to your apps, APIs, databases and AI models. Self-hosting means that engine runs on a machine you control instead of on n8n's managed service.

The editor is the same either way. What changes is who does the server work. On your own server you choose the version, the database, the domain and the city your data lives in. In return, updates, backups and security are your job. Nobody patches it for you.

Self-host when

  • Workflows run often and you would rather pay one flat server price than watch plan limits.
  • Credentials, customer data or files should stay on a server you control.
  • You need community nodes, extra npm packages in Code nodes, or access to databases and services on a private network.

Choose n8n Cloud when

  • Nobody on your team wants to look after a Linux server.
  • You want updates, backups and the server itself looked after for you.
  • You are only exploring n8n and do not want to set anything up yet.

Self-hosting trades a managed service for control. The server, the data and the upkeep all become yours.

We do not list n8n Cloud prices here because they change from time to time. Check n8n's own site for its current plans.

Step 3

How much server does n8n need?

n8n sits quietly when it is idle and gets hungry when big workflows run. Four facts from n8n's documentation do most of the sizing work:

  • Memory matters more than CPU. n8n holds the data of a running workflow in memory, so large payloads, files and many parallel runs need RAM first.
  • SQLite is the default database, and n8n recommends PostgreSQL for production.
  • Queue mode, where several workers share the load, needs PostgreSQL and Redis.
  • The AI Assistant: n8n's Docker guide asks for at least 2 vCPUs and 4 GB of RAM when you use it.

Memory, not CPU, is usually the first thing an n8n server runs out of.

Our rule of thumb: 1 GB of RAM is enough to learn n8n and run a few test workflows. For production, start at 2 GB. Go to 4 GB or more for AI nodes or big files, and 8 GB or more for many parallel workflows or queue mode. CPU only becomes the limit when heavy Code nodes run all day, which is when dedicated cores pay off.

Want a server already sized and installed? Our n8n VPS plans start at $6.39/mo billed yearly with n8n pre-installed. To compare every size and location, see the VPS pricing page.

Tip: Workflow history grows over time. n8n prunes old execution data by default, so check the pruning settings fit how long you want to keep run logs, and move to PostgreSQL before your workflows become business critical.

Part 2: Install n8n

Pick one route: let the checkout install n8n for you in one click, or install it yourself with Docker and PostgreSQL on any Ubuntu server.

Step 4

Option A: install n8n in one click on VPSPulse

If you would rather skip Docker and Compose, let the checkout do the install. n8n comes pre-selected and the server boots with n8n on Ubuntu 22.04.

  1. Pick a plan and a city

    Open the checkout with the button below, choose a size from the section above and the city closest to you or to the APIs your workflows call. There are 12 cities in 12 countries to choose from.

  2. Pay and wait a few minutes

    Pay by card, PayPal, bank transfer or cryptocurrency, monthly or yearly (yearly saves 20%). The server is ready in minutes, and you receive its dedicated IPv4 address and login details.

  3. Open n8n and create the owner account

    Open n8n in your browser and set up the owner account, the admin login for your instance.

  4. Finish the setup

    Add your domain and HTTPS, close unused ports and set up backups with the sections further down. It is a normal Linux server with full root access, so everything in this guide applies.

Deploy n8n

From $6.39/mo billed yearly · 7-day refund for new customers

Good to know: Before you change a one-click install, check how n8n runs on that server (for example, docker ps lists running Docker containers), so your changes go to the right place.

Other tools install the same way. Browse the full list of one-click apps.

Step 5

Option B: install n8n manually with Docker

n8n's documentation suggests Docker for most self-hosted setups: the same image on every server, isolated from the rest of the system and simple to update. These steps work on any Ubuntu server, ours or anyone else's.

Your server Firewall: only 22, 80 and 443 open Browsersand webhooks Caddy or NginxHTTPS on 443 PostgreSQL n8n_dataDocker volume n8n 127.0.0.1:5678
Figure 1. What you will build: a reverse proxy takes HTTPS traffic, n8n listens only on the server itself, and PostgreSQL plus a Docker volume keep the data.

Step 6

Install Docker Engine

Follow Docker's official install guide for Ubuntu. It adds Docker's own package repository and includes the Compose plugin. Then check that both work:

docker --versiondocker compose version

Step 7

Try n8n with one command

Create a volume for n8n's data, then start a container from the official image. This is the quick start from n8n's Docker guide:

docker volume create n8n_data docker run -it --rm --name n8n -p 5678:5678 \  -v n8n_data:/home/node/.n8n \  docker.n8n.io/n8nio/n8n

n8n now listens on port 5678, and the volume keeps your workflows, credentials and encryption key when the container is removed. Press Ctrl+C to stop it. This is good for a first look, but it uses SQLite, has no HTTPS and stops when you close the terminal. Opening it over plain http from another computer also shows a secure-cookie warning (see troubleshooting).

Step 8

Write a Docker Compose file with PostgreSQL

For production, n8n recommends PostgreSQL. Create a folder such as ~/n8n and put this in docker-compose.yml. Replace n8n.your-domain.com, the time zone, both <version> placeholders and the password, and use a long random password.

docker-compose.yml
services:  postgres:    image: postgres:<version>    restart: unless-stopped    environment:      - POSTGRES_USER=n8n      - POSTGRES_PASSWORD=change-me      - POSTGRES_DB=n8n    volumes:      - db_data:/var/lib/postgresql/data   n8n:    image: docker.n8n.io/n8nio/n8n:<version>    restart: unless-stopped    ports:      - "127.0.0.1:5678:5678"    environment:      - DB_TYPE=postgresdb      - DB_POSTGRESDB_HOST=postgres      - DB_POSTGRESDB_PORT=5432      - DB_POSTGRESDB_DATABASE=n8n      - DB_POSTGRESDB_USER=n8n      - DB_POSTGRESDB_PASSWORD=change-me      - N8N_HOST=n8n.your-domain.com      - N8N_PROTOCOL=https      # n8n older than 2.30: use WEBHOOK_URL instead      - N8N_WEBHOOK_URL=https://n8n.your-domain.com/      - GENERIC_TIMEZONE=Europe/Berlin      - TZ=Europe/Berlin    volumes:      - n8n_data:/home/node/.n8n    depends_on:      - postgres volumes:  db_data:  n8n_data:

The port is bound to 127.0.0.1 on purpose: only the reverse proxy on the same server can reach n8n, not the whole internet.

Step 9

Start n8n and watch the logs

From the folder with the Compose file, start both containers in the background and follow n8n's log:

cd ~/n8ndocker compose up -ddocker compose logs -f n8n

When the log says the editor is accessible, n8n is running. Press Ctrl+C to leave the log; the containers keep running, and restart: unless-stopped brings them back after a reboot.

Step 10

The settings that matter

Most problems with a self-hosted n8n come from a handful of environment variables. This is what each one in the file does:

Key n8n environment variables for a Docker Compose setup
VariableWhat it does
N8N_HOSTThe domain n8n runs on, for example n8n.your-domain.com.
N8N_PROTOCOLhttps once n8n sits behind your reverse proxy.
N8N_WEBHOOK_URLThe public address n8n uses to build webhook URLs. Recent versions (2.30 and later) read this name; older versions read WEBHOOK_URL.
GENERIC_TIMEZONEThe time zone for Schedule triggers and other time-based nodes.
DB_TYPEpostgresdb switches n8n from the default SQLite to PostgreSQL.
DB_POSTGRESDB_*Host, port, database, user and password of the PostgreSQL server (there is also DB_POSTGRESDB_SCHEMA if you need a schema other than the default).
N8N_ENCRYPTION_KEYOptional. The key n8n uses to encrypt saved credentials. If you do not set it, n8n creates a random one on first start and stores it in its data volume.

Watch out: Pin the versions you choose: replace <version> with a current n8n release tag and a PostgreSQL major version that n8n supports, so updates only happen when you decide. To keep passwords out of the YAML, Compose can read them from a .env file in the same folder (write ${POSTGRES_PASSWORD} in the file instead of the value).

Part 3: Domain, HTTPS and first login

Webhooks, OAuth logins and n8n's secure cookies all expect HTTPS. The usual setup is a reverse proxy on the same server: it answers on ports 80 and 443, gets a free TLS certificate and forwards requests to n8n on port 5678.

Step 11

Point your domain at the server

At your DNS host, create an A record for n8n.your-domain.com with your server's IPv4 address. Wait until the name resolves before you ask for a certificate.

Step 12

Add Caddy as the reverse proxy

Caddy is the shortest path, because it requests and renews certificates on its own. Install it from Caddy's official packages, then replace the contents of /etc/caddy/Caddyfile with:

/etc/caddy/Caddyfile
n8n.your-domain.com {    reverse_proxy localhost:5678}

Reload Caddy with sudo systemctl reload caddy. A minute later, https://n8n.your-domain.com should open the n8n editor.

Tip: Running Caddy in Docker as well? Then localhost means the Caddy container itself. Put Caddy in the same Compose file and point it at the service name instead: reverse_proxy n8n:5678.

Step 13

Prefer Nginx? Same idea, a few more lines

Proxy the site to http://127.0.0.1:5678, use HTTP/1.1 and pass the Upgrade and Connection headers, because the editor keeps a live WebSocket connection open. Then get a certificate with Certbot.

Step 14

Check that n8n knows its address

N8N_HOST, N8N_PROTOCOL=https and the webhook URL in your Compose file must match the domain. After any change, run docker compose up -d again so the container picks it up.

Step 15

Create the owner account and test a webhook

Open https://n8n.your-domain.com. On the first visit n8n asks you to set up the owner account, the admin user of the instance. Use a long, unique password from a password manager, then go to Settings > Profile & preferences and turn on two-factor authentication.

To check the whole chain, build a tiny workflow: a Webhook trigger followed by any other node. Look at the production URL n8n shows for the webhook. It should start with https://n8n.your-domain.com, not localhost:5678. Turn the workflow on and call the URL from your browser or with curl. If the run shows up in the executions list, your server, proxy and n8n are wired up correctly.

Part 4: Secure, back up and update n8n

A self-hosted n8n holds the keys to every app it connects to. Treat the server like a password vault.

Step 16

Open only the ports you need

Keep SSH (22), HTTP (80) and HTTPS (443) open and close everything else. With UFW on Ubuntu:

sudo ufw allow OpenSSHsudo ufw allow 80/tcpsudo ufw allow 443/tcpsudo ufw enable

Watch out: Docker publishes ports by writing its own firewall rules, and those rules skip UFW. A container started with -p 5678:5678 can be reached from the internet even when UFW blocks port 5678. Bind it to 127.0.0.1:5678:5678, as the Compose file above does.

Step 17

Work through the security checklist

  • Log in with SSH keys and switch off password logins. Our VPS setup guide shows how.
  • Keep Ubuntu patched. Install updates regularly; Ubuntu's unattended-upgrades package can apply security updates for you.
  • Update n8n on a schedule, not only when something breaks. The next section shows how.
  • Guard the encryption key. Lose it and saved credentials cannot be decrypted. Leak it together with your database and anyone can read them. Store a copy somewhere safe, away from the server.
  • Give every person their own n8n account with two-factor authentication, instead of sharing the owner login.
  • Be picky about community nodes. They run code on your server, so install only the ones you trust.

Good to know: Every VPSPulse server includes DDoS protection, which helps keep your webhooks reachable when someone floods the server with traffic. It complements the steps above; it does not replace them.

Step 18

What to back up

  • The n8n_data volume: n8n's settings and its encryption key, plus the database itself if you still use SQLite.
  • The PostgreSQL database, where workflows, credentials and execution history live in a Compose setup.
  • Your docker-compose.yml and .env files, so you can rebuild the server exactly.

Step 19

Export workflows and credentials with the n8n CLI

n8n's command line tool exports everything to JSON. Run it inside the container, then copy the files out:

cd ~/n8ndocker compose exec -u node n8n n8n export:workflow --all --output=/home/node/.n8n/workflows.jsondocker compose exec -u node n8n n8n export:credentials --all --output=/home/node/.n8n/credentials.jsondocker compose cp n8n:/home/node/.n8n/workflows.json ./docker compose cp n8n:/home/node/.n8n/credentials.json ./

Good to know: Credentials are exported encrypted with your instance's key, so the file is only useful together with that key. Keep both, but store them in different places. (n8n can also export them decrypted with --decrypted; then the file contains every secret in plain text.)

Step 20

Dump the PostgreSQL database

A database dump captures everything, including execution history:

docker compose exec -T postgres pg_dump -U n8n n8n > n8n-$(date +%F).sql

Copy the dumps and exports off the server, for example with scp or rsync, and practise a restore once on a spare server so you know it works.

Step 21

Update n8n safely

  1. Read the release notes

    n8n publishes notes for every release. Look for breaking changes before a big jump.

  2. Back up first

    Run the exports and the database dump above. Updates can change the database, so a backup is your reliable way back.

  3. Pull the new image and recreate

    Change the version tag in docker-compose.yml if you pinned one, then run the commands below.

  4. Check the result

    Follow the log until the editor is accessible, then open a few workflows and run one by hand.

cd ~/n8ndocker compose pulldocker compose downdocker compose up -d

Started n8n with plain docker run? Pull the new image with docker pull docker.n8n.io/n8nio/n8n, stop and remove the old container, then start it again with the same command. Your data is in the volume, so nothing is lost.

Tip: Small, regular updates are easier to test and easier to undo than skipping many versions at once.

Part 5: Move your workflows and fix problems

Coming from n8n Cloud, or stuck on an error message? These two steps cover both.

Step 22

Move your workflows from n8n Cloud

Moving to your own server is mostly copy and paste, with one catch: secrets do not travel with the workflows.

  1. Download each workflow

    In n8n Cloud, open a workflow, open its menu and choose Download. You get a JSON file with every node and setting.

  2. Import it on your server

    In your own n8n, create a workflow and choose Import from File in the same menu. For a whole folder of files, the CLI can import them at once (copy the folder into the container first).

    docker compose cp ./exported n8n:/home/node/.n8n/importdocker compose exec -u node n8n n8n import:workflow --separate --input=/home/node/.n8n/import
  3. Re-create the credentials

    Workflow files refer to credentials but do not contain the secrets. Add each credential again, then open the nodes that use it and select it. For OAuth apps, copy the new OAuth redirect URL n8n shows and add it in that app's developer settings.

  4. Point webhooks at the new address

    Every service that calls one of your webhooks needs the new URL on your domain. Test each workflow, switch it on, then switch the old one off in n8n Cloud.

Tip: Move a few low-risk workflows first and run them side by side with the old ones for a day or two before you switch everything over.

Step 23

Troubleshooting common problems

Most self-hosting issues fall into a few patterns. Find the symptom, then check the likely cause.

Common self-hosted n8n problems, their causes and fixes
SymptomLikely causeWhat to do
Webhook URLs show localhost:5678n8n does not know its public address behind the proxySet N8N_WEBHOOK_URL (or WEBHOOK_URL on older versions) to https://n8n.your-domain.com/ and run docker compose up -d.
A warning about a secure cookie when you open n8nYou are on plain http, for example the IP address and port 5678Open n8n through your domain with HTTPS. For a short local test only, N8N_SECURE_COOKIE=false switches the check off.
The editor keeps losing its connectionThe proxy drops WebSocket connectionsIn Nginx, use HTTP/1.1 to n8n and pass the Upgrade and Connection headers. Caddy handles this on its own.
Workflows stop with out-of-memory errorsLarge payloads or files held in memory at onceProcess items in batches with the Loop Over Items node, split the work into sub-workflows, or move to a server with more RAM.
The disk fills up over timeLong execution history, big binary files, old Docker imagesTune pruning with EXECUTIONS_DATA_MAX_AGE and EXECUTIONS_DATA_PRUNE_MAX_COUNT, and remove unused images with docker image prune.
Permission denied on the data folderA host folder mounted instead of a named volume, owned by rootn8n runs as the node user (UID 1000) in the container. Give that user the folder with sudo chown -R 1000:1000, or use a named volume.
Saved credentials suddenly fail to decryptThe encryption key changed, often after starting with a fresh data volumeRestore the old n8n_data volume or set the original N8N_ENCRYPTION_KEY.

Why run n8n on a VPSPulse server

n8n pre-installed

Pick n8n at checkout and the server boots with n8n on Ubuntu 22.04, ready in minutes.

Full root access

It is a normal Linux server, so every step in this guide still applies.

DDoS protection included

It helps keep your webhooks reachable when someone floods the server with traffic.

12 cities in 12 countries

Run n8n close to you or to the APIs your workflows call.

FAQ

Self-hosting n8n: frequently asked questions

How do I update self-hosted n8n?

Back up first, then pull the new image and recreate the container. With Docker Compose that is docker compose pull, docker compose down and docker compose up -d in the folder with your Compose file. If you pinned a version tag, change it before you pull. Read n8n's release notes for breaking changes before a big jump.

How do I back up a self-hosted n8n?

Back up three things: the n8n data volume (it holds the encryption key), the database (a pg_dump if you use PostgreSQL), and your Compose and .env files. You can also export workflows and credentials to JSON with n8n export:workflow --all and n8n export:credentials --all. Keep copies off the server and test a restore once.

Should I install n8n with Docker or npm?

Docker is the route n8n's documentation suggests for most self-hosted setups: the image bundles the right Node.js version, keeps n8n isolated and makes updates a matter of pulling a new image. Installing with npm works too, but you manage Node.js versions and the process yourself, so it suits development machines more than servers.

How do I set the webhook URL for n8n behind a reverse proxy?

Set N8N_WEBHOOK_URL to your public address with a trailing slash, for example https://n8n.your-domain.com/, and recreate the container. n8n versions older than 2.30 read WEBHOOK_URL instead. Also set N8N_HOST and N8N_PROTOCOL=https so the editor and its links match your domain.

How do I switch n8n from SQLite to PostgreSQL?

Set DB_TYPE=postgresdb and the DB_POSTGRESDB_ host, port, database, user and password variables, then restart n8n. n8n starts with an empty PostgreSQL database and does not copy your SQLite data across, so export your workflows and credentials with the n8n CLI first and import them afterwards, keeping the same encryption key.

Is self-hosted n8n secure?

It can be, but the security is in your hands. Keep only SSH, HTTP and HTTPS open, bind n8n to 127.0.0.1 behind an HTTPS reverse proxy, log in with SSH keys, use two-factor authentication in n8n, update Ubuntu and n8n regularly, install only community nodes you trust, and keep the encryption key and backups safe.

Can I run n8n without a domain name?

For a quick test, yes: open the server's IP address on port 5678. n8n expects HTTPS, though, so plain http triggers its secure-cookie warning, and many services refuse to call webhooks that are not on HTTPS. For anything real, use a domain or subdomain with a TLS certificate.

What happens if I lose the n8n encryption key?

Saved credentials can no longer be decrypted, so every app connection has to be set up again. The key lives in the n8n data volume unless you set N8N_ENCRYPTION_KEY yourself. Back it up, store it apart from the database backups, and reuse it when you move or rebuild the server.

Sources: n8n's self-hosting documentation and Docker's Ubuntu install guide. Version numbers and settings change between releases, so check them against the docs for the version you install.

Next: read our guide to setting up a VPS, or browse all VPS guides.

Skip the setup: deploy n8n in one click from $6.39/mo

We install n8n on Ubuntu 22.04 for you, on a server with full root access, a dedicated IPv4 address and DDoS protection, in 12 cities. Everything in this guide still applies when you want to tune it.

Choosing a location first? See all VPS locations.