M
MJK.Supplies
Home / n8n / Self-hosting n8n: a production-grade setup guide…
n8n

Self-hosting n8n: a production-grade setup guide

Self-hosting n8n is not hard. Running it reliably in production, at scale, with proper security, backups, and the ability to handle workflow failures gracefully — that takes more care. The default n8n Docker setup gets you a working instance in twenty minutes. What it doesn't give you is queue mode for concurrent execution, worker nodes for load distribution, a backup strategy, or the security defaults that should be on before the instance is exposed to the internet. This guide covers everything between 'docker run n8n' and a setup you'd be comfortable running business-critical workflows on.

M
MJK Supplies · May 30, 2026 · 15 min read
ShareXinf↗
Self-hosting n8n: a production-grade setup guide

Architecture: main instance vs. queue mode

The default n8n setup runs everything in a single process: the web UI, the API, the workflow scheduler, and the workflow execution engine. This works well for development and low-volume use. In production, it has a critical limitation: if a long-running workflow ties up the process, new workflows queue behind it. If your instance has memory pressure, a single misbehaving workflow can take down the UI and stop new executions entirely.

Queue mode separates concerns. The main instance handles the UI and API. Worker instances handle workflow execution. A Redis queue sits between them — the main instance adds jobs to the queue, workers pick them up and execute them. You can run multiple workers, distributing execution across machines. If a worker goes down, other workers continue processing. If you need more capacity, you add workers.

For production use handling more than 100 workflows per day or any workflow that takes more than a few seconds to execute, queue mode is not optional. The operational overhead of running Redis and separate worker instances is minimal compared to the reliability improvement. The sections below cover the full setup, but start with the queue mode decision before anything else.

# docker-compose.yml (queue mode) services: n8n-main: image: n8nio/n8n environment: - EXECUTIONS_MODE=queue - QUEUE_BULL_REDIS_HOST=redis - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY} ports: - "5678:5678" n8n-worker: image: n8nio/n8n command: worker environment: - EXECUTIONS_MODE=queue - QUEUE_BULL_REDIS_HOST=redis - N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY} scale: 3 redis: image: redis:7-alpine volumes: - redis_data:/data

Database: moving off SQLite

n8n defaults to SQLite for its internal database. SQLite is fine for development. In production, it has three problems: it doesn't support concurrent writes (a problem with multiple workers), it's hard to back up reliably while the instance is running, and it grows without bound as execution history accumulates. Migrate to PostgreSQL before you put anything important on the instance.

Set up a Postgres database with a dedicated user and a separate schema for n8n. The connection string goes in the DB_POSTGRESDB_* environment variables. Run n8n once to apply the schema migrations, verify the tables are created, and then export any existing data from SQLite if you have workflows you want to keep. The migration is a one-time operation and n8n handles it automatically on first start with Postgres configured.

Execution history in Postgres grows significantly with high-volume usage. Configure EXECUTIONS_DATA_PRUNE to delete old execution data automatically. We keep 30 days of execution history for most workflows and 90 days for business-critical ones. Add a Postgres maintenance job to run VACUUM ANALYZE weekly — n8n's execution log creates a lot of dead tuples under high write volume.

Security defaults that must be set before going live

The n8n defaults are not production security defaults. Several settings need to change before your instance is exposed to the internet. First: disable basic auth if you're using it and set up proper authentication. n8n supports SAML and LDAP in the enterprise version, or you can place it behind an auth proxy like Authentik or Authelia that handles authentication at the reverse proxy layer before requests reach n8n.

The N8N_ENCRYPTION_KEY environment variable must be set to a strong random value before your first run. This key encrypts stored credentials. If you lose it, you lose access to all stored credentials. If you change it without proper migration, existing credentials become unusable. Generate it once, store it in your secrets manager, and treat it with the same care you'd treat a private key.

Restrict the webhook URL if your instance is exposed publicly. Anyone who can guess your webhook paths can trigger your workflows. Use the WEBHOOK_URL environment variable to set the public URL, ensure HTTPS is enforced at the reverse proxy, and consider adding webhook authentication (a shared secret in the webhook path or header) for any webhook that triggers sensitive operations. Don't rely on security through obscurity — use real authentication.

  • Set N8N_ENCRYPTION_KEY before first run, store in secrets manager
  • Enable HTTPS via reverse proxy (Caddy or Nginx with Let's Encrypt)
  • Configure authentication — auth proxy or n8n's built-in user management
  • Restrict EXECUTIONS_DATA_MAX_AGE to avoid unbounded database growth
  • Disable the n8n diagnostics and usage telemetry in air-gapped environments
  • Set up network-level access controls — n8n should not be publicly accessible on port 5678

Backup strategy: what to back up and how

The data you care about in n8n falls into three categories: workflow definitions, credential configurations, and execution history. Workflow definitions are the most critical — losing them means losing all your automation logic. Credential configurations are next — losing them means re-entering all API keys and tokens. Execution history is useful for debugging but is the least critical to restore.

Back up the Postgres database daily with pg_dump. Store the backup in a separate location from the instance — at minimum an S3 bucket in a different region. Test the restore process quarterly: spin up a fresh n8n instance, restore the database dump, and verify that workflows load and credentials are accessible. An untested backup is not a backup.

n8n also exposes an API for exporting workflows in JSON format. Running a nightly n8n workflow that calls the API and commits workflow JSON to a git repository gives you version-controlled workflow history — you can see exactly what changed in each workflow over time and roll back to a previous version if needed. This is separate from the database backup and complements it.

Monitoring and alerting for production instances

A production n8n instance needs monitoring at two levels: infrastructure health and workflow health. Infrastructure health means the instance is running, memory and CPU are within bounds, and the database connection is live. Workflow health means critical workflows are executing on schedule and not failing silently.

For infrastructure health, basic uptime monitoring with a tool like Uptime Kuma (which can itself run as a Docker container on the same host) handles the basics. Set up alerts for the main n8n endpoint, the Redis connection, and the Postgres connection. A dead Redis instance stops all queued workflow execution while the main instance continues to appear healthy — monitoring only the main instance isn't enough.

For workflow health, n8n's built-in error workflow feature is underused. Configure a global error workflow that fires whenever any workflow fails. The error workflow receives the error details, the workflow ID, and the execution context. Use it to send a Slack alert with enough context to debug the failure — the workflow name, the node that failed, and the error message. Without this, workflow failures are silent until a business outcome fails.

Managing updates without downtime

n8n releases updates frequently, and they occasionally include breaking changes. Running on the latest version is important for security patches, but uncontrolled updates in production environments cause incidents. The update strategy that works best in production: pin the Docker image to a specific version, test updates on a staging instance first, and deploy to production during low-traffic windows.

Before any update, back up the database. Read the n8n release notes carefully — they flag breaking changes and required migration steps. After the update, verify that all previously-working workflows still execute correctly by running a test execution on each critical workflow manually. The staging environment test catches most issues, but production sometimes has subtle differences in configuration or data.

For zero-downtime updates with queue mode, update worker instances first while the main instance continues serving UI requests and queuing new jobs. Once workers are on the new version and stable, update the main instance. Active jobs may fail during the main instance restart — configure your critical workflows with retry logic so they recover automatically when the main instance comes back up.

Frequently Asked Questions

Is n8n free to self-host?↓
Yes. n8n's community edition is free and open source — you can self-host it on any server with no per-execution fees. You pay only for infrastructure: a $6-12/month VPS handles most small-to-medium workloads. The paid cloud plan ($20/month) is available if you don't want to manage infrastructure. Enterprise features (SSO, audit logs, advanced permissions) require an enterprise licence.
What are the minimum server requirements to self-host n8n?↓
The minimum for a basic n8n self-hosted setup is 1 vCPU and 1GB RAM. For production workloads with concurrent executions, 2 vCPU and 2GB RAM is recommended. Queue mode (for high-volume production) additionally requires Redis. A $10-20/month VPS from DigitalOcean, Hetzner, or Linode is sufficient for most small businesses running 10-50 active workflows.
How do I back up a self-hosted n8n instance?↓
Back up two things: the SQLite database file (or Postgres database if using Postgres) which stores all workflow definitions and credentials, and the n8n environment variables file which contains your encryption key. Without the encryption key, encrypted credentials in the database are unrecoverable. Automate daily database backups to S3 or similar. The n8n data directory is typically at ~/.n8n/ on the host or /home/node/.n8n/ inside the Docker container.
Can n8n handle high-volume automation without degrading?↓
Yes, with queue mode enabled. Queue mode uses Redis as a job broker and allows you to run multiple worker instances processing jobs in parallel. This scales to thousands of executions per hour. Without queue mode (default), n8n processes executions sequentially in a single process — fine for low to medium volume but will back up under load. Enable queue mode before you need it, not after you hit the wall.
What is the difference between n8n cloud and n8n self-hosted?↓
n8n cloud is the managed SaaS version — no infrastructure to manage, automatic updates, but with per-execution pricing ($20/month for 2,500 executions). Self-hosted is free and unlimited but requires you to manage the server, updates, backups, and uptime. For teams with technical resources and high execution volume, self-hosted is cheaper. For teams without infrastructure experience, cloud is simpler and more reliable.
#n8n#self-hosting#devops#production

Related articles

MJK Supplies · Automation Services

Want this built for you?

We design and ship custom AI agents and automation systems for teams that want results, not a backlog. Book a free 30-minute consult — no commitment, no pitch deck.