How to Self-Host n8n: Complete Setup Guide 2025

Complete technical guide to install and manage n8n on your own server. Docker setup, security, SSL certificates, backups and monitoring included.

Self-hosting n8n gives you complete control over your automation workflows and data. This comprehensive guide will walk you through every step of setting up n8n on your own server, from initial installation to production-ready configuration with security, SSL, and monitoring.

Why Self-Host n8n?

  • Complete data privacy and control
  • Full customization and integration options
  • Cost-effective for heavy usage
  • Meet compliance requirements
  • Better performance for complex workflows

Prerequisites

Before starting the installation, ensure you have the following requirements met:

Server Requirements

  • 2+ CPU cores
  • 4GB+ RAM
  • 20GB+ SSD storage
  • Ubuntu 20.04+ / CentOS 8+

Software Requirements

  • Docker 20.10+
  • Docker Compose 2.0+
  • Git
  • Nginx (optional)

Network Requirements

  • Domain name
  • SSL certificate
  • Ports 80, 443 open
  • SSH access

Docker Setup

We'll use Docker to ensure a consistent and easy-to-manage n8n installation. Here's how to install Docker and Docker Compose:

Install Docker

First, update your system and install Docker:

# Update system packages
sudo apt update && sudo apt upgrade -y

# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

# Add user to docker group
sudo usermod -aG docker $USER

# Start and enable Docker
sudo systemctl start docker
sudo systemctl enable docker

Install Docker Compose

Install the latest version of Docker Compose:

# Download Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

# Make it executable
sudo chmod +x /usr/local/bin/docker-compose

# Verify installation
docker-compose --version

Verify Installation

Test that Docker is working correctly:

# Test Docker installation
docker run hello-world

# Check Docker status
sudo systemctl status docker

n8n Installation

Now we'll create a Docker Compose configuration to run n8n with a PostgreSQL database:

Create Docker Compose File

Create a directory for n8n and set up the Docker Compose configuration:

# Create directory
mkdir -p ~/n8n && cd ~/n8n

# Create docker-compose.yml
cat > docker-compose.yml << 'EOF'
version: '3.8'

services:
  postgres:
    image: postgres:13
    restart: always
    environment:
      POSTGRES_DB: n8n
      POSTGRES_USER: n8n
      POSTGRES_PASSWORD: n8n_password
    volumes:
      - postgres_data:/var/lib/postgresql/data
    networks:
      - n8n-network

  n8n:
    image: n8nio/n8n:latest
    restart: always
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: postgres
      DB_POSTGRESDB_PORT: 5432
      DB_POSTGRESDB_DATABASE: n8n
      DB_POSTGRESDB_USER: n8n
      DB_POSTGRESDB_PASSWORD: n8n_password
      N8N_ENCRYPTION_KEY: your_encryption_key_here
      WEBHOOK_URL: https://yourdomain.com
      GENERIC_TIMEZONE: Europe/Madrid
      N8N_SECURE_COOKIE: false
    ports:
      - "5678:5678"
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres
    networks:
      - n8n-network

volumes:
  postgres_data:
  n8n_data:

networks:
  n8n-network:
    driver: bridge
EOF

Important Security Note

Make sure to replace the default passwords and encryption key with strong, unique values before running the configuration in production.

Ready to Start Your n8n Journey?

Skip the complex setup and get n8n running in minutes with our managed hosting service. Professional support, automatic updates, and enterprise-grade security included.

  • 5-minute setup
  • 24/7 support
  • Automatic backups
  • SSL included
  • 99.9% uptime
  • EU servers
Back to Blog Start Free Trial