Monday, 20 October 2025

How to Self-Host n8n: Step-by-Step Guide

 How to Self-Host n8n: Step-by-Step Guide



Introduction

n8n (pronounced "n-eight-n") is a powerful open-source workflow automation tool that allows you to connect different apps, APIs, and services — similar to Zapier or Make (Integromat), but fully customizable and self-hostable.

By self-hosting n8n, you gain:

  • Full control over your data

  • Unlimited workflows and executions

  • Custom integrations and scalability

  • No vendor lock-in

This guide walks you through every step to self-host n8n on your own server or local environment.

Prerequisites

Before you start, make sure you have:

Basic knowledge of the command line

A server (VPS or cloud instance) with at least:

1 GB RAM (2 GB recommended), 10 GB disk space

Docker and Docker Compose installed

A domain name (optional but recommended for HTTPS)

Node.js (if you plan to install manually)


Installation Methods Overview

There are three common ways to self-host n8n:

  1. Using Docker (Recommended)

  2. Using npm (Node.js)

  3. Using a Cloud Provider (e.g., Railway, Render, etc.)

We’ll focus on Docker Compose, as it’s the easiest and most stable setup.

Installing n8n with Docker Compose

Step 1: Create a Project Directory

mkdir n8n-selfhost
cd n8n-selfhost

Step 2: Create a docker-compose.yml File

version: "3.8"

services:
  n8n:
    image: n8nio/n8n:latest
    restart: always
    ports:
      - "5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=yourpassword
      - N8N_HOST=yourdomain.com
      - N8N_PORT=5678
      - NODE_ENV=production
      - WEBHOOK_TUNNEL_URL=https://yourdomain.com/
    volumes:
      - ./n8n_data:/home/node/.n8n

Start the Container

docker-compose up -d

Step 4: Access n8n

Open your browser and visit:
👉 http://localhost:5678

Log in using your credentials (admin / yourpassword).

Setting Up HTTPS (Optional but Recommended)

If you have a domain, you can enable HTTPS using Traefik or NGINX Reverse Proxy.

Example (with Traefik):

services:
  n8n:
    image: n8nio/n8n
    environment:
      - N8N_HOST=yourdomain.com
      - N8N_PROTOCOL=https
      - WEBHOOK_TUNNEL_URL=https://yourdomain.com/
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.n8n.rule=Host(`yourdomain.com`)"
      - "traefik.http.routers.n8n.entrypoints=websecure"
      - "traefik.http.routers.n8n.tls.certresolver=letsencrypt"

This setup automatically generates a free SSL certificate using Let’s Encrypt.

Persistent Data Storage

All workflow data is stored in the /home/node/.n8n directory inside the container.
In the Docker Compose file, this directory is mapped to your local machine via:


volumes:

  - ./n8n_data:/home/node/.n8n

This ensures your workflows persist even if the container restarts or updates.

Updating n8n

To update to the latest version:

docker-compose pull

docker-compose up -d

Your data and workflows remain safe in n8n_data.

Backup and Restore

Backup

Simply back up your n8n_data folder:

tar -czvf n8n_backup.tar.gz ./n8n_data

Restore

Extract the backup to the same directory:

tar -xzvf n8n_backup.tar.gz -C ./n8n_data

Then restart the container.

Common Issues & Solutions


Conclusion

Self-hosting n8n empowers you to automate tasks securely and flexibly — all under your control. Whether for business operations, app integrations, or personal productivity, n8n can be your central automation hub.

With Docker Compose, installation and management are straightforward, and you can scale up as your workflows grow.


No comments:

Post a Comment