Back to Blog
n8n

How to Run n8n on a VPS: Best Practices for 2025

October 2, 2025·2 min read·Amit El
How to Run n8n on a VPS: Best Practices for 2025

Choosing the Right VPS Provider

Not all VPS providers are created equal for running n8n. Here's what to look for:

  • Minimum: 2GB RAM, 1 vCPU, 25GB SSD
  • Recommended: 4GB RAM, 2 vCPU, 50GB SSD
  • Production: 8GB RAM, 4 vCPU, 100GB SSD

Top VPS Providers for n8n

DigitalOcean: $12/month for 2GB RAM - Best for beginners with great documentation

Linode (Akamai): $12/month for 2GB RAM - High performance

Hetzner: €4.51/month for 4GB RAM - Best value for Europe

Vultr: $12/month for 2GB RAM - Global locations

Initial VPS Setup

1. Secure Your Server

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

# Create non-root user
sudo adduser n8nuser
sudo usermod -aG sudo n8nuser

# Set up SSH keys (disable password auth)
sudo nano /etc/ssh/sshd_config
# Set: PasswordAuthentication no

# Enable firewall
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

2. Install Docker

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker n8nuser

# Install 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
sudo chmod +x /usr/local/bin/docker-compose

Production-Ready n8n Configuration

Complete Docker Compose Setup

version: '3.8'

services:
  postgres:
    image: postgres:15
    restart: unless-stopped
    environment:
      POSTGRES_DB: n8n
      POSTGRES_USER: n8n
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U n8n"]
      interval: 10s
      timeout: 5s
      retries: 5

  n8n:
    image: n8nio/n8n:latest
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
      - N8N_HOST=${DOMAIN}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://${DOMAIN}/
      - GENERIC_TIMEZONE=${TIMEZONE}
      - N8N_ENCRYPTION_KEY=${ENCRYPTION_KEY}
    ports:
      - "5678:5678"
    volumes:
      - n8n_data:/home/node/.n8n
      - ./workflows:/workflows

volumes:
  postgres_data:
  n8n_data:

FlowEngine: Managed n8n Without the Hassle

Setting up and maintaining n8n on a VPS requires significant DevOps knowledge. FlowEngine provides production-ready n8n instances for free with:

  • Automatic backups and disaster recovery
  • SSL certificates managed for you
  • Automatic updates and security patches
  • Built-in monitoring and alerting
  • 99.9% uptime SLA
  • AI workflow assistant built on top of n8n

Save $144+/year on VPS costs and countless hours on maintenance - get started with FlowEngine today.

n8nVPShostingtutorial