N8N Self-Hosted: How to Host Your Own Instance

Step-by-step guide to hosting self-hosted N8N. Compare self-hosting vs cloud and discover how lui.cx facilitates N8N hosting in Brazil.

N8N is one of the most powerful automation tools on the market, and one of its biggest advantages is the possibility of being self-hosted — that is, hosted on your own infrastructure. In this guide, we'll explore what it means to host N8N, how to do it in practice, the challenges involved, and how lui.cx can simplify this entire process.

What is self-hosting?

Self-hosting is the practice of running software on your own servers, instead of depending on the supplier's infrastructure. In the case of N8N, this means installing and running the platform on a server that you control, be it a VPS (Virtual Private Server), a dedicated server or even a local machine.

Advantages of self-hosted N8N

  • Full data control: Your automation data, credentials and workflows live exclusively on your server. This is crucial for companies that need to comply with LGPD or other data protection regulations.

  • No execution limits: Unlike N8N Cloud, which charges for executions, the self-hosted version has no limits. You can run as many workflows as you want, as many times as you need.

  • Full customization: You can configure the environment exactly how you need it, install community nodes, adjust memory limits, and customize the instance.

  • Predictable cost: Instead of paying per run (which can scale quickly), you just pay for the server. For high-volume operations, this represents significant savings.

  • Low latency: Hosting in Brazil, your automations that interact with Brazilian services and APIs will have much lower latency than on servers abroad.

Disadvantages of manual self-hosting

  • Requires technical knowledge in Linux, Docker and networks
  • Responsibility for updates and security
  • Need to configure backups manually
  • Continuous monitoring and maintenance
  • Troubleshooting on your own

Requirements for hosting N8N

Before you start, you need to meet some minimum requirements:

Hardware (server/VPS)

Feature Minimum Recommended
CPU 1 vCPU 2+ vCPUs
RAM 1GB 2+ GB
Storage 10GB SSD 20+ GB SSD
Bandwidth 1 TB/month 2+ TB/month

For production environments with many active workflows, consider at least 4 GB of RAM and 2 vCPUs. Memory consumption scales with the number of concurrent executions and the complexity of the streams.

Software

  • Operating system: Ubuntu 22.04+ or Debian 12+ (recommended)
  • Docker: Version 20.10+ and Docker Compose v2
  • Node.js: Version 18+ (if installed without Docker)
  • Database: SQLite (default) or PostgreSQL (recommended for production)
  • Reverse proxy: Nginx or Caddy (for SSL and custom domain)

Network

  • A domain or subdomain pointing to the server IP
  • Ports 80 and 443 released on the firewall
  • SSL Certificate (can be generated with Let’s Encrypt)

Step-by-step guide: installing N8N with Docker

The most practical way to install N8N is using Docker Compose. Here is a complete tutorial.

Step 1: Prepare the server

Connect to your server via SSH and update packages:

sudo apt update && sudo apt upgrade -y

Step 2: Install Docker

Install Docker and Docker Compose:

curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER

Log out and log back in for the Docker group permissions to be applied.

Step 3: Create the directory structure

mkdir -p ~/n8n-docker
cd ~/n8n-docker

Step 4: Create the Docker Compose file

Create the file docker-compose.yml:

version: "3.8"

services:
  n8n:
    image: n8nio/n8n:latest
    restart: always
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=seu-dominio.com.br
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://seu-dominio.com.br/
      - GENERIC_TIMEZONE=America/Sao_Paulo
      - TZ=America/Sao_Paulo
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=SuaSenhaSegura123
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

Replace seu-dominio.com.br with your real domain and change the authentication password.

Step 5: Configure Nginx as a reverse proxy

Install Nginx:

sudo apt install nginx -y

Create the configuration for the N8N:

server {
    listen 80;
    server_name seu-dominio.com.br;

    location / {
        proxy_pass http://localhost:5678;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
        proxy_cache off;
        chunked_transfer_encoding off;
    }
}

Step 6: Configure SSL with Let’s Encrypt

Install Certbot and generate the certificate:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d seu-dominio.com.br

Certbot will automatically configure HTTPS in Nginx and schedule automatic certificate renewal.

Step 7: Start N8N

cd ~/n8n-docker
docker compose up -d

The N8N will be accessible at https://seu-dominio.com.br.

Step 8: Configure backups

Create a backup script to run daily:

#!/bin/bash
BACKUP_DIR="/home/$USER/n8n-backups"
DATE=$(date +%Y%m%d_%H%M%S)

mkdir -p $BACKUP_DIR

docker exec n8n-docker-n8n-1 n8n export:workflow --all \
  --output="$BACKUP_DIR/workflows_$DATE.json"

docker exec n8n-docker-n8n-1 n8n export:credentials --all \
  --output="$BACKUP_DIR/credentials_$DATE.json"

find $BACKUP_DIR -mtime +30 -delete

Schedule execution with cron:

crontab -e
# Adicione:
0 3 * * * /home/$USER/n8n-backup.sh

Advanced settings for production

Using PostgreSQL instead of SQLite

For production environments, PostgreSQL offers better performance and reliability. Update the docker-compose.yml:

version: "3.8"

services:
  postgres:
    image: postgres:16
    restart: always
    environment:
      - POSTGRES_USER=n8n
      - POSTGRES_PASSWORD=SenhaDoPostgres
      - POSTGRES_DB=n8n
    volumes:
      - postgres_data:/var/lib/postgresql/data

  n8n:
    image: n8nio/n8n:latest
    restart: always
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=SenhaDoPostgres
      - N8N_HOST=seu-dominio.com.br
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://seu-dominio.com.br/
      - GENERIC_TIMEZONE=America/Sao_Paulo
      - TZ=America/Sao_Paulo
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres

volumes:
  n8n_data:
  postgres_data:

Configuring execution limits

To prevent poorly configured workflows from consuming all server resources:

- EXECUTIONS_TIMEOUT=300
- EXECUTIONS_TIMEOUT_MAX=600
- N8N_PAYLOAD_SIZE_MAX=16

Monitoring with healthcheck

Add a healthcheck to the N8N service to ensure the container is working:

healthcheck:
  test: ["CMD", "wget", "--spider", "-q", "http://localhost:5678/healthz"]
  interval: 30s
  timeout: 10s
  retries: 3

The real challenges of self-hosting

While the above tutorial seems simple, the reality of maintaining a self-hosted N8N in production involves ongoing challenges:

Security updates

N8N and its dependencies receive regular updates. Keeping everything up to date requires constant attention to avoid exposing your server to vulnerabilities. A poorly done update can bring down your entire automation.

Scalability

As your workflows grow in number and complexity, resource consumption increases. Knowing when and how to scale the server, optimize database queries, and manage memory requires technical expertise.

Availability

Ensuring N8N is available 24/7 is non-trivial. Server outages, network issues, disk exhaustion, and other issues can disrupt your automations at critical times.

Disaster recovery

What happens if the server fails completely? Having a disaster recovery strategy with tested backups, documentation and restoration procedures is essential, but often overlooked.

How lui.cx solves these challenges

A lui.cx was created specifically to solve the challenges of self-hosted N8N. We offer managed hosting with all the flexibility of self-hosting, without the operational complexity:

Optimized infrastructure

Our servers are dedicated VPS in Brazil, configured specifically for the N8N. Each customer receives their own isolated instance, ensuring consistent performance and security.

Setup in minutes

Instead of hours configuring a server, Docker, Nginx and SSL, with lui.cx you have your N8N up and running in minutes. Just sign up, choose your plan, and your instance is automatically provisioned.

Automatic backups

We perform automatic daily backups of all workflows, credentials and data. In case of any problem, restoration is quick and without data loss.

Managed updates

Our team monitors N8N versions and applies updates securely, testing compatibility before updating your instance. You always run the latest version without risk.

Specialized support in Portuguese

Our team knows N8N in depth and offers technical support in Portuguese. Whether the issue is a webhook configuration or a complex integration, we're here to help.

24/7 monitoring

We monitor the health of your instance continuously. If something goes out of order, we act proactively before it impacts your automations.

Conclusion

The self-hosted N8N is a powerful option for those looking for full control over their automations. However, maintaining the infrastructure yourself requires time, technical knowledge and constant attention.

If you want the benefits of self-hosted N8N without the headaches, lui.cx offers the best combination: dedicated instance, data in Brazil, optimized performance and specialized support. Start today and automate your business with peace of mind.

Explore all articles