n8n Queue Mode Setup for Scaling Workflows
In this article
n8n queue mode lets you run workflow executions across multiple worker processes instead of a single main instance. This is essential when you need to scale beyond the default limits, handle high-volume workloads, or ensure that long-running workflows don't block others. In queue mode, the main instance only handles the editor UI and API, while jobs are pushed to a message broker (Redis) and picked up by workers. This guide walks you through the setup step by step.
What You'll Need
- An existing n8n installation (Docker, npm, or binary) that you can reconfigure.
- Access to a Redis server (version 6.2 or higher recommended). You can use a managed service (e.g., Redis Cloud) or run your own instance.
- Basic familiarity with environment variables and your deployment method (Docker Compose, systemd, etc.).
- If you use Docker, ensure you can modify your compose file and restart containers.
- For external workers, you'll need separate machines or containers that can reach the same Redis instance and your database (PostgreSQL or SQLite).
Step-by-Step
- Set up Redis – Ensure your Redis server is running and accessible from all n8n instances. If you're using Docker, you can start a Redis container with:
docker run --name redis -p 6379:6379 -d redis:7. For production, use a password and TLS if possible. - Choose your database – Queue mode works best with PostgreSQL. If you're still on SQLite, migrate to PostgreSQL first (n8n provides a built-in migration command). For Docker Compose, add a PostgreSQL service or point to an external one.
- Configure the main instance – Set the environment variable
EXECUTIONS_MODE=queue. This tells the main instance to stop processing executions directly and instead push them to Redis. - Set Redis connection variables – Add
QUEUE_BULL_REDIS_HOST(default: localhost),QUEUE_BULL_REDIS_PORT(default: 6379), and optionallyQUEUE_BULL_REDIS_PASSWORDandQUEUE_BULL_REDIS_DB. Example:QUEUE_BULL_REDIS_HOST=redisif your Redis container is named 'redis'. - Set a shared database URL – Ensure
DB_TYPE=postgresdbandDB_POSTGRESDB_DATABASE,DB_POSTGRESDB_HOST,DB_POSTGRESDB_PORT,DB_POSTGRESDB_USER,DB_POSTGRESDB_PASSWORDare set identically on all instances. This is crucial for workers to see the same workflows and executions. - Start the main instance – With the above variables set, start your main n8n process. It will now only serve the UI and API, and will not execute workflows itself.
- Start worker processes – On any machine (or container) that can reach Redis and the database, start n8n with the same environment variables plus
EXECUTIONS_MODE=queueandN8N_ROLE=worker. This launches a worker that pulls jobs from Redis. - Scale workers – You can start as many workers as you need. Each worker can also handle multiple concurrent executions by setting
EXECUTIONS_PROCESS=queue(default) and tuning concurrency. To adjust concurrency per worker, setQUEUE_WORKER_CONCURRENCY(default: 10). - Verify setup – In the main instance UI, go to Settings > Usage. You should see the queue mode indicator. Run a simple test workflow and watch the execution logs – the job should be picked up by a worker.
- Update your start scripts – For Docker Compose, define separate services: one for the main instance (with
N8N_ROLE=mainor unset) and one for workers (withN8N_ROLE=worker). Use the same image and environment, but override the command for workers.
Common Mistakes
- Forgetting to set
EXECUTIONS_MODE=queueon workers – Workers will still try to execute locally, causing errors or duplicate runs. - Using different database credentials across instances – Workers must use the exact same database connection string as the main instance, or they won't see workflows.
- Not configuring Redis persistence – If Redis restarts and loses jobs, executions may be lost. Enable Redis AOF persistence for production.
- Running workers without the same version of n8n – Mismatched versions can cause protocol errors; always use the same n8n version across all instances.
- Ignoring network latency – If workers are in a different region than Redis, latency can cause timeouts. Keep them in the same network.
Tips
- Use Docker Compose with a
workerservice that hasreplicasset to your desired number. This makes scaling as easy asdocker-compose up --scale worker=5. - Monitor Redis memory and CPU. Use tools like Redis CLI
INFOor a dashboard to watch for bottlenecks. - Set
QUEUE_WORKER_CONCURRENCYbased on your workflow complexity. If workflows are I/O-heavy, increase concurrency; if CPU-heavy, decrease it. - Use the
N8N_ENCRYPTION_KEYenvironment variable to set a fixed encryption key across all instances. This is essential for workers to decrypt credentials stored in the database. - Test your setup with a few test workflows before moving production traffic.
Troubleshooting
- Workers not picking up jobs – Check Redis connectivity:
redis-cli pingfrom the worker. Verify that the queue name is the same (default isjobs). EnsureEXECUTIONS_MODE=queueis set on the main instance. - Executions stuck in 'waiting' – This usually means no worker is available. Check that at least one worker is running and connected to the same Redis database (check
QUEUE_BULL_REDIS_DB). - Errors about missing credentials – Workers cannot decrypt credentials unless
N8N_ENCRYPTION_KEYis set identically on all instances. Set it and restart all processes. - Database connection errors – Ensure the database is reachable from all instances. Check firewall rules and that the database user has permission to connect from all IPs.
- High memory usage on workers – Reduce
QUEUE_WORKER_CONCURRENCYor add more workers instead of increasing concurrency. - After upgrading n8n, workers fail – Always upgrade workers and the main instance in the same maintenance window. Restart all processes after upgrade.
Frequently Asked Questions
Do I need Redis for queue mode?
Yes, Redis is the message broker that n8n uses to distribute jobs to workers. It's a required component.
Can I run the main instance and workers on the same machine?
Yes, you can run them as separate processes or containers on the same host. However, for true scaling, you'll want workers on separate machines.
How many workers should I run?
Start with one or two and monitor performance. Add more as needed. There's no hard limit, but each worker consumes memory and CPU.
Will queue mode work with SQLite?
It's not recommended. SQLite doesn't handle concurrent access well, and workers may conflict. Use PostgreSQL for production.
Can I change from queue mode back to regular mode?
Yes, simply set EXECUTIONS_MODE=regular and restart. Your workflows and data remain intact.
Do I need to change my workflows to work in queue mode?
No, workflows are the same. However, avoid using local file paths or in-memory data that won't be shared across workers. Use n8n's data store or external storage for shared state.