Skip to content

Set Up n8n on a Linux Server – Build Powerful Workflow Automations

Discover how to install and configure n8n for self-hosting to create smart AI workflow automations that make your work easier → Learn more now

10 November 20264 min read2 Views0 helpful

Introduction

n8n is a leading visual editor for rapid iterations, allowing you to build automation workflows and see results immediately. Perfect for everyday automations and complex AI agent workflows.

Self-hosting support and the low-code editor make n8n a favorite among developers. If you want maximum control, customizations, and long-term cost savings, the self-hosted version is the right choice for you.

Want to self-host n8n? We guide you step-by-step through setup and configuration, showing you everything you need to know.

Requirements

Although n8n is lightweight, resource usage can increase with the number of workflows, API calls, and data-intensive nodes. We recommend the following hardware specs for your VPS to host n8n:

HardwareMinimumRecommended
CPU1 vCPU core2 vCPU cores
RAM2 GB4 GB
Storage20 GB50 GB

Installation

Once Docker is running on your server, verify the installation with:

Code
docker --version
docker compose version

Create a .env File

Create a project directory to store n8n local files and environment variables, then navigate into it:

Code
mkdir n8n-compose
cd n8n-compose

In the n8n-compose directory, create a .env file with nano .env and add the following code with n8n environment variables:

Code
# DOMAIN_NAME and SUBDOMAIN together define the address where n8n is accessible
# The top-level domain
DOMAIN_NAME=zap.cloud

# The subdomain
SUBDOMAIN=silver-octopus-xxxxx

# The example above makes n8n accessible at: https://silver-octopus-xxxxx.zap.cloud

# Optional timezone used by Cron and other scheduling nodes
GENERIC_TIMEZONE=Europe/Berlin

# Email address for TLS/SSL certificate creation
SSL_EMAIL=hello@zap-hosting.com
Info
To find DOMAIN_NAME and SUBDOMAIN, go to your ZAP-Hosting product page, open your VPS, and check the Hostname.

Enter the part zap.cloud as DOMAIN_NAME and the first part as SUBDOMAIN (e.g., silver-octopus-xxxxx).

Warning

HTTPS Requirement Do not use a plain IP address in the .env file. n8n requires an HTTPS connection, and SSL certificates are only issued for domains, not IP addresses.

If you prefer to host n8n on your own domain, create a subdomain for n8n by adding an A record in your domain’s DNS manager pointing to your VPS’s IP.

NameTypeValueTTLPriority
n8n (subdomain)AIPv4 address14400

Create Local Directory for Files

Inside the project folder, create another folder named local-files to share files between the n8n instance and the host system:

Code
mkdir local-files

Create Docker Compose File

Create the Docker Compose file compose.yaml with nano compose.yaml and add the following content:

yaml
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: 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
      - 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
      - N8N_RUNNERS_ENABLED=true
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - TZ=${GENERIC_TIMEZONE}
    volumes:
      - n8n_data:/home/node/.n8n
      - ./local-files:/files

volumes:
  n8n_data:
  traefik_data:

This installs n8n, issues an SSL certificate, configures it, and makes n8n live on your domain.

Start n8n

Start n8n with:

Code
sudo docker compose up -d

You can stop n8n with:

Code
sudo docker compose stop

Access n8n

After starting, open n8n in your browser via the URL (or hostname if used). You will first need to create an admin account.

Info

Remember your password Keep your password safe for later use!

Then a short survey appears where you enter some basic info.

Optionally, you can get free access to some paid features by entering your email and receiving a license key by mail. If interested, enter your email and request the license key.

The license key arrives immediately by email. Copy it and enter it in Settings > Usage & Plans > Enter Activation Key.

Create Your First Workflow

Then you can go straight to the dashboard and start using n8n!

Start with a blank canvas or use a pre-made template. Your n8n installation is ready!

FAQ

Frequently asked questions

You can install n8n directly via One-Click Apps in the VPS web interface by searching for n8n in the app catalog and starting the installation with your preferred project, environment, and domain settings.
n8n is a leading visual editor for rapid iterations that lets you build automation workflows—from everyday automations to complex AI agent workflows.
n8n offers over 1367 integrations including Google Sheets, Telegram, MySQL, Slack, Discord, and Postgres.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 Users found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.