FlexoHost Logo
FlexoHost Logo
Back to guides
VPS5 min readNov 8, 2026

How to Install n8n on a VPS with Docker (Step by Step, 2026)

Install self-hosted n8n on an Ubuntu VPS with Docker Compose, free SSL and your own domain. Server size, setup steps, updates and backups.

FlexoHost Team

Technical guides & hosting tips

On this page
How to Install n8n on a VPS with Docker (Step by Step, 2026)

n8n is a workflow automation tool that connects apps like Google Sheets, WhatsApp, WooCommerce and OpenAI. Running it on your own VPS means no per-execution fees and your workflows stay on your server. This guide installs n8n with Docker Compose, the setup n8n documents for servers, with free SSL on your own subdomain.

Disclosure: FlexoHost wrote this guide and sells VPS plans. The steps work on any Ubuntu VPS. If you would rather not do it yourself, our n8n hosting includes setup.

What you need

Item Recommendation
VPS Ubuntu 22.04 or 24.04, at least 2 GB RAM (4 GB for daily business use)
Domain A subdomain such as n8n.yourdomain.com
Access SSH login from your welcome email
Time About 20 minutes

Not sure about the location? Choose a BDIX VPS if your workflows serve people in Bangladesh (bots, website webhooks), or a USA VPS if they mostly call international APIs such as OpenAI. See USA VPS vs BDIX VPS.

Step 1: point your subdomain to the VPS

In your domain's DNS settings, add an A record:

  • Name: n8n
  • Value: your VPS IP address

DNS can take a few minutes to a few hours to update. You can check it with the Domain Checker.

Step 2: connect to the server

From Windows (PowerShell), macOS or Linux:

ssh root@YOUR_SERVER_IP

Then update the system:

sudo apt update && sudo apt upgrade -y

Step 3: install Docker and Docker Compose

Docker publishes a convenience script that installs Docker Engine and the Compose plugin:

curl -fsSL https://get.docker.com | sudo sh

Check that both work:

docker --version
docker compose version

Step 4: create the n8n folder and settings

mkdir n8n-compose && cd n8n-compose
mkdir local-files
nano .env

Paste this into .env and change the values to your own:

DOMAIN_NAME=yourdomain.com
SUBDOMAIN=n8n
GENERIC_TIMEZONE=Asia/Dhaka
SSL_EMAIL=you@yourdomain.com

With these values n8n will open at https://n8n.yourdomain.com. Save with Ctrl+O, then exit with Ctrl+X.

Step 5: create the Docker Compose file

nano compose.yaml

Paste this file. Traefik handles https and the free certificate; n8n only listens on the server itself.

services:
  traefik:
    image: "traefik"
    restart: always
    command:
      - "--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: docker.n8n.io/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
    environment:
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - N8N_WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - N8N_RESTRICT_FILE_ACCESS_TO=/files
    volumes:
      - n8n_data:/home/node/.n8n
      - ./local-files:/files

volumes:
  n8n_data:
  traefik_data:

Newer n8n versions read N8N_WEBHOOK_URL; older ones read WEBHOOK_URL, so the file sets both.

Step 6: start n8n

sudo docker compose up -d

Wait a minute for the certificate, then open https://n8n.yourdomain.com. Create the owner account on the first screen. Do this straight away, before anyone else can reach the page.

Step 7: keep it updated and backed up

Update to the latest version:

cd ~/n8n-compose
sudo docker compose pull
sudo docker compose up -d

Your workflows and credentials live in the n8n_data Docker volume. Export important workflows from the n8n editor regularly, and keep server backups.

Common problems

Problem What to check
Browser shows a certificate warning DNS may not point to the VPS yet. Wait, then restart with sudo docker compose up -d
Site does not open at all Ports 80 and 443 must be open in any firewall
Webhooks show the wrong address Check SUBDOMAIN and DOMAIN_NAME in .env, then restart
n8n becomes slow or stops The server may be out of memory. Check with free -h and consider 4 GB RAM

Prefer not to do it yourself?

FlexoHost's n8n hosting is a VPS with n8n installed by our team, on BDIX (Dhaka) or USA servers, paid in taka with bKash. You can also run Hermes Agent or OpenClaw on the same server if it has enough memory.

Source for the Docker Compose layout: n8n documentation, "Use Docker Compose".

সাধারণ জিজ্ঞাসা (FAQ)

How much RAM do I need for n8n on a VPS?

n8n does not publish a fixed minimum. 2 GB is enough for a few light workflows. For daily business automation and AI Agent nodes, 4 GB is a safer choice.

Is self-hosted n8n free?

Yes. Without a licence key n8n runs as the free Community edition, so you only pay for the server. Some business features need a paid n8n licence.

Do I need a domain name to run n8n?

It is strongly recommended. With a domain (or subdomain) pointed at your VPS, Traefik can get a free SSL certificate, and webhooks from other services can reach n8n over https.

How do I update n8n installed with Docker Compose?

In your n8n folder run 'sudo docker compose pull' and then 'sudo docker compose up -d'. Your workflows stay in the n8n_data volume.

Can FlexoHost install n8n for me?

Yes. If you order an n8n VPS from FlexoHost, our team sets up n8n for you, and you still get full root access.

কোনটা নেবেন বুঝতে পারছেন না?

৫টা প্রশ্নের উত্তর দিন, ১ মিনিটে আপনার সাইটের জন্য সঠিক প্ল্যান আর দাম দেখুন।

প্ল্যান খুঁজুন

Need fast hosting for your website?

NVMe SSD, LiteSpeed, free SSL and 24/7 support, with servers in Bangladesh (BDIX) and abroad.

Related guides

Need Help? We Are Here To Help You

Please feel free to consult with one of our experts, who will thoroughly evaluate your specific requirements and provide a tailored proposal that perfectly aligns with your company's unique needs and realities.