<figure class="wp-block-image aligncenter"><img src="https://flowgenius.in/wp-content/uploads/2026/01/n8n-queue-mode-incorrect-environment-mode.png" alt="Step by Step Guide to solve n8n queue mode incorrect environment mode" /><figcaption style="text-align: center;">Step by Step Guide to solve n8n queue mode incorrect environment mode</p>
<hr />
</figcaption></figure>
<p style="margin-bottom: 2em; line-height: 1.9;"><strong>Who this is for:</strong> n8n administrators and DevOps engineers who manage multiple n8n environments (dev, staging, prod) and need to guarantee that workflow executions stay within the correct queue. <strong>We cover this in detail in the </strong><a href="https://flowgenius.in/n8n-queue-mode-error-guide/">n8n Queue Mode Errors Guide.</a></p>
<hr style="margin: 55px 0; border: none; border-top: 1px solid #eee;" />
<h2 style="margin-bottom: 45px; line-height: 1.3;">Quick Diagnosis</h2>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 2em; line-height: 1.9;">
<thead>
<tr>
<th style="border: 1px solid #ddd; padding: 13px;">Symptom</th>
<th style="border: 1px solid #ddd; padding: 13px;">Likely Cause</th>
<th style="border: 1px solid #ddd; padding: 13px;">One‑line Fix</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">Production jobs appear in the dev queue (or vice‑versa)</td>
<td style="border: 1px solid #ddd; padding: 13px;">`QUEUE_MODE` does not match the current `NODE_ENV`</td>
<td style="border: 1px solid #ddd; padding: 13px;">Align `QUEUE_MODE` with `NODE_ENV` and restart the n8n service</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">“Queue mode mismatch” error in logs (<code>Error: Queue mode does not match environment</code>)</td>
<td style="border: 1px solid #ddd; padding: 13px;">Missing or mistyped env var (`QUEUE_MODE=production` vs `QUEUE_MODE=prod`)</td>
<td style="border: 1px solid #ddd; padding: 13px;">Correct the variable name/value in <code>.env</code> or Docker‑Compose</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">Staging jobs are processed by production workers</td>
<td style="border: 1px solid #ddd; padding: 13px;">`QUEUE_MODE` forced to `production` in a staging deployment</td>
<td style="border: 1px solid #ddd; padding: 13px;">Override `QUEUE_MODE=staging` in the staging compose file</td>
</tr>
</tbody>
</table>
<blockquote style="margin: 0 0 2em 0; padding-left: 1em; border-left: 4px solid #ddd; font-style: italic;">
<p style="margin-bottom: 0; line-height: 1.9;">Set <code>QUEUE_MODE</code> to <code>development</code>, <code>staging</code>, or <code>production</code> so it matches <code>NODE_ENV</code>. Restart n8n and confirm with <code>GET /health/queue-mode</code> – the response should show the same mode as your environment.</p>
</blockquote>
<hr style="margin: 55px 0; border: none; border-top: 1px solid #eee;" />
<h2 style="margin-bottom: 45px; line-height: 1.3;">1. How n8n Determines Queue Mode ?</h2>
<p style="margin-bottom: 2em; line-height: 1.9;"><em>Micro‑summary:</em> n8n reads two environment variables; <code>QUEUE_MODE</code> selects the Redis namespace, while <code>NODE_ENV</code> defines the overall runtime profile. If you encounter any <a href="/n8n-queue-mode-environment-variable-missing">n8n queue mode environment variable missing </a>resolve them before continuing with the setup.</p>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 2em; line-height: 1.9;">
<thead>
<tr>
<th style="border: 1px solid #ddd; padding: 13px;">Variable</th>
<th style="border: 1px solid #ddd; padding: 13px;">Accepted Values</th>
<th style="border: 1px solid #ddd; padding: 13px;">Effect</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">`NODE_ENV`</td>
<td style="border: 1px solid #ddd; padding: 13px;">`development` | `staging` | `production`</td>
<td style="border: 1px solid #ddd; padding: 13px;">Sets logging level, debug tools, etc.</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">`QUEUE_MODE`</td>
<td style="border: 1px solid #ddd; padding: 13px;">`development` | `staging` | `production`</td>
<td style="border: 1px solid #ddd; padding: 13px;">Chooses the queue namespace (<code>n8n:dev</code>, <code>n8n:stage</code>, <code>n8n:prod</code>). If omitted, n8n falls back to <code>NODE_ENV</code>.</td>
</tr>
</tbody>
</table>
<p style="margin-bottom: 2em; line-height: 1.9;"><strong>EEFA note:</strong> In production always set <code>QUEUE_MODE=production</code>. Relying on fallback can be overridden by an accidental <code>.env</code> file on a staging host, causing cross‑environment job leakage.</p>
<hr style="margin: 55px 0; border: none; border-top: 1px solid #eee;" />
<h2 style="margin-bottom: 45px; line-height: 1.3;">2. Symptoms of a Wrong Environment Mode</h2>
<p style="margin-bottom: 2em; line-height: 1.9;"><em>Micro‑summary:</em> Look for cross‑environment execution, rate‑limit anomalies, and mismatched health‑check data.</p>
<ol style="margin-bottom: 1.8em; line-height: 1.9;">
<li><strong>Cross‑environment job execution</strong> – Production UI jobs are picked up by dev workers.</li>
<li><strong>Unexpected rate‑limits</strong> – Dev queues have lower concurrency; production jobs stall.</li>
<li><strong>Log noise</strong> – Production logs contain <code>[DEV]</code> tags, confusing alerts.</li>
<li><strong>Health‑check mismatch</strong> – <code>GET /health/queue-mode</code> returns a mode that doesn’t match the service URL.</li>
</ol>
<p style="margin-bottom: 2em; line-height: 1.9;">If any appear, proceed to verification.</p>
<hr style="margin: 55px 0; border: none; border-top: 1px solid #eee;" />
<h2 style="margin-bottom: 45px; line-height: 1.3;">3. Verify Current Queue Mode</h2>
<h3 style="margin-bottom: 40px; line-height: 1.3;">3.1 Inspect environment variables inside the container</h3>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9; margin-bottom: 2em;"># Docker
docker exec -it n8n_container env | grep -E 'NODE_ENV|QUEUE_MODE'</pre>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9; margin-bottom: 2em;"># Kubernetes pod
kubectl exec -it $(kubectl get pod -l app=n8n -o jsonpath="{.items[0].metadata.name}") -- env | grep -E 'NODE_ENV|QUEUE_MODE'</pre>
<h3 style="margin-bottom: 40px; line-height: 1.3;">3.2 Call the health endpoint</h3>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9; margin-bottom: 2em;">curl -s http://localhost:5678/health/queue-mode | jq .</pre>
<p style="margin-bottom: 2em; line-height: 1.9;">Expected JSON:</p>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9; margin-bottom: 2em;">{
"queueMode": "production",
"nodeEnv": "production"
}</pre>
<p style="margin-bottom: 2em; line-height: 1.9;"><strong>EEFA warning:</strong> Do not expose <code>/health/queue-mode</code> publicly. Restrict it to internal IPs or protect it with an auth token.</p>
<h3 style="margin-bottom: 40px; line-height: 1.3;">3.3 Cross‑reference with deployment config</h3>
<p style="margin-bottom: 2em; line-height: 1.9;">Make sure the values printed match the intended environment (development, staging, production).</p>
<hr style="margin: 55px 0; border: none; border-top: 1px solid #eee;" />
<h2 style="margin-bottom: 45px; line-height: 1.3;">4. Correct Configuration per Environment</h2>
<p style="margin-bottom: 2em; line-height: 1.9;">Below are minimal, production‑ready snippets. Each block is limited to 4‑5 lines and is preceded by a short description.</p>
<h3 style="margin-bottom: 40px; line-height: 1.3;">4.1 Development (local Docker)</h3>
<p style="margin-bottom: 2em; line-height: 1.9;">*Use an in‑memory queue and run executions in the main process.*</p>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9; margin-bottom: 2em;">services:
n8n:
image: n8nio/n8n:latest
environment:</pre>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9; margin-bottom: 2em;"> - NODE_ENV=development
- QUEUE_MODE=development
- EXECUTIONS_PROCESS=main
ports:
- "5678:5678"</pre>
<h3 style="margin-bottom: 40px; line-height: 1.3;">4.2 Staging (Docker Swarm / Kubernetes)</h3>
<p style="margin-bottom: 2em; line-height: 1.9;">*Isolate staging jobs with a dedicated Redis instance.*</p>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9; margin-bottom: 2em;">services:
n8n:
image: n8nio/n8n:2.0.0
environment:</pre>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9; margin-bottom: 2em;"> - NODE_ENV=staging
- QUEUE_MODE=staging
- REDIS_URL=redis://redis-staging:6379
deploy:
replicas: 3</pre>
<h3 style="margin-bottom: 40px; line-height: 1.3;">4.3 Production (Kubernetes Helm)</h3>
<p style="margin-bottom: 2em; line-height: 1.9;">*Pin the image, enforce resource limits, and keep a PodDisruptionBudget.*</p>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9; margin-bottom: 2em;">n8n:
env:
NODE_ENV: production
QUEUE_MODE: production
REDIS_URL: redis://redis-prod:6379
resources:
limits:</pre>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9;"> cpu: "4"
memory: "8Gi"
replicaCount: 5</pre>
<p style="margin-bottom: 2em; line-height: 1.9;"><strong>Key points for all environments</strong></p>
<ul style="margin-bottom: 1.8em; line-height: 1.9;">
<li><strong>Never</strong> set <code>QUEUE_MODE=production</code> in a non‑production deployment.</li>
<li>Use a dedicated Redis instance per environment to keep namespaces isolated.</li>
<li>In production, lock the image tag (<code>n8nio/n8n:2.0.0</code>) to avoid accidental upgrades.</li>
<li>If you encounter any <a href="/n8n-queue-mode-proxy-configuration-error">n8n queue mode proxy configuration error </a>resolve them before continuing with the setup.</li>
</ul>
<hr style="margin: 55px 0; border: none; border-top: 1px solid #eee;" />
<h2 style="margin-bottom: 45px; line-height: 1.3;">5. Troubleshooting Checklist</h2>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 2em; line-height: 1.9;">
<thead>
<tr>
<th style="border: 1px solid #ddd; padding: 13px;">Check</th>
<th style="border: 1px solid #ddd; padding: 13px;">How to Verify</th>
<th style="border: 1px solid #ddd; padding: 13px;">Fix if Failing</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">Env vars are present</td>
<td style="border: 1px solid #ddd; padding: 13px;"><code>docker exec … env \| grep QUEUE_MODE</code></td>
<td style="border: 1px solid #ddd; padding: 13px;">Add missing var to <code>.env</code>, Docker‑Compose, or Helm values</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">Values match (<code>QUEUE_MODE</code> = <code>NODE_ENV</code>)</td>
<td style="border: 1px solid #ddd; padding: 13px;">Compare printed values</td>
<td style="border: 1px solid #ddd; padding: 13px;">Align them (both <code>production</code>, <code>staging</code>, or <code>development</code>)</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">Redis namespace correct</td>
<td style="border: 1px solid #ddd; padding: 13px;"><code>redis-cli KEYS "n8n:*"</code> – look for <code>n8n:prod</code> vs <code>n8n:dev</code></td>
<td style="border: 1px solid #ddd; padding: 13px;">Adjust <code>QUEUE_MODE</code> and restart workers</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">Worker pods use correct config</td>
<td style="border: 1px solid #ddd; padding: 13px;"><code>kubectl describe pod <worker></code> → env section</td>
<td style="border: 1px solid #ddd; padding: 13px;">Redeploy with corrected Helm chart</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">Health endpoint reports correct mode</td>
<td style="border: 1px solid #ddd; padding: 13px;"><code>curl …/health/queue-mode</code></td>
<td style="border: 1px solid #ddd; padding: 13px;">Restart n8n after fixing env vars</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">No stray <code>.env</code> files</td>
<td style="border: 1px solid #ddd; padding: 13px;"><code>git ls-files | grep .env</code></td>
<td style="border: 1px solid #ddd; padding: 13px;">Remove or rename files on staging/production hosts</td>
</tr>
</tbody>
</table>
<p style="margin-bottom: 2em; line-height: 1.9;"><strong>EEFA note:</strong> After any change, flush the old‑mode queue to avoid orphaned jobs.</p>
<pre style="background: #fafafa; padding: 20px; border: 1px solid #e0e0e0; overflow: auto; white-space: pre-wrap; word-wrap: break-word; line-height: 1.9; margin-bottom: 2em;"># Example for Redis – delete keys from the dev namespace
redis-cli -n 0 KEYS "n8n:dev:*" | xargs -r redis-cli -n 0 DEL</pre>
<p style="margin-bottom: 2em; line-height: 1.9;">Run this only during a maintenance window; deleting the wrong keys can lose in‑flight executions.</p>
<hr style="margin: 55px 0; border: none; border-top: 1px solid #eee;" />
<h2 style="margin-bottom: 45px; line-height: 1.3;">6. When to Use Explicit <code>QUEUE_MODE</code> Overrides</h2>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 2em; line-height: 1.9;">
<thead>
<tr>
<th style="border: 1px solid #ddd; padding: 13px;">Scenario</th>
<th style="border: 1px solid #ddd; padding: 13px;">Recommended Setting</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">Hybrid CI/CD pipelines where the same Docker image runs in both staging and prod</td>
<td style="border: 1px solid #ddd; padding: 13px;">Set <code>QUEUE_MODE</code> via runtime overrides (<code>docker run -e QUEUE_MODE=staging …</code>) rather than baking it into the image.</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">Feature‑flag testing that needs a temporary dev queue in prod</td>
<td style="border: 1px solid #ddd; padding: 13px;">Use <code>QUEUE_MODE=development</code> <strong>only</strong> on a dedicated “sandbox” worker pool, isolated by a separate Redis DB (<code>REDIS_URL=redis://redis-sandbox:6379</code>).</td>
</tr>
<tr>
<td style="border: 1px solid #ddd; padding: 13px;">Multi‑tenant SaaS with per‑tenant queue namespaces</td>
<td style="border: 1px solid #ddd; padding: 13px;">Prefix the mode with tenant ID (<code>QUEUE_MODE=production-tenant42</code>). See the sibling page “n8n queue mode custom namespace” for implementation details.</td>
</tr>
</tbody>
</table>
<p> </p>
<hr style="margin: 55px 0; border: none; border-top: 1px solid #eee;" />
<h2 style="margin-bottom: 45px; line-height: 1.3;">Bottom Line</h2>
<p style="margin-bottom: 2em; line-height: 1.9;">The “wrong environment mode” error is always a mis‑aligned <code>QUEUE_MODE</code> / <code>NODE_ENV</code> pair. Explicitly set both variables in your deployment manifest, verify with the health endpoint, and purge any stray queues before restarting. Following the checklist guarantees that each n8n instance processes only the jobs meant for its environment, preserving data integrity and operational stability.</p>
Step by Step Guide to solve n8n queue mode incorrect environment mode
Who this is for: n8n administrators and DevOps engineers who manage multiple n8n environments (dev, staging, prod) and need to guarantee that workflow executions stay within the correct queue. We cover this in detail in the n8n Queue Mode Errors Guide.
Quick Diagnosis
Symptom
Likely Cause
One‑line Fix
Production jobs appear in the dev queue (or vice‑versa)
`QUEUE_MODE` does not match the current `NODE_ENV`
Align `QUEUE_MODE` with `NODE_ENV` and restart the n8n service
“Queue mode mismatch” error in logs (Error: Queue mode does not match environment)
Missing or mistyped env var (`QUEUE_MODE=production` vs `QUEUE_MODE=prod`)
Correct the variable name/value in .env or Docker‑Compose
Staging jobs are processed by production workers
`QUEUE_MODE` forced to `production` in a staging deployment
Override `QUEUE_MODE=staging` in the staging compose file
Set QUEUE_MODE to development, staging, or production so it matches NODE_ENV. Restart n8n and confirm with GET /health/queue-mode – the response should show the same mode as your environment.
1. How n8n Determines Queue Mode ?
Micro‑summary: n8n reads two environment variables; QUEUE_MODE selects the Redis namespace, while NODE_ENV defines the overall runtime profile. If you encounter any n8n queue mode environment variable missing resolve them before continuing with the setup.
Variable
Accepted Values
Effect
`NODE_ENV`
`development` | `staging` | `production`
Sets logging level, debug tools, etc.
`QUEUE_MODE`
`development` | `staging` | `production`
Chooses the queue namespace (n8n:dev, n8n:stage, n8n:prod). If omitted, n8n falls back to NODE_ENV.
EEFA note: In production always set QUEUE_MODE=production. Relying on fallback can be overridden by an accidental .env file on a staging host, causing cross‑environment job leakage.
2. Symptoms of a Wrong Environment Mode
Micro‑summary: Look for cross‑environment execution, rate‑limit anomalies, and mismatched health‑check data.
Cross‑environment job execution – Production UI jobs are picked up by dev workers.
Unexpected rate‑limits – Dev queues have lower concurrency; production jobs stall.
Log noise – Production logs contain [DEV] tags, confusing alerts.
Health‑check mismatch – GET /health/queue-mode returns a mode that doesn’t match the service URL.
If any appear, proceed to verification.
3. Verify Current Queue Mode
3.1 Inspect environment variables inside the container
Add missing var to .env, Docker‑Compose, or Helm values
Values match (QUEUE_MODE = NODE_ENV)
Compare printed values
Align them (both production, staging, or development)
Redis namespace correct
redis-cli KEYS "n8n:*" – look for n8n:prod vs n8n:dev
Adjust QUEUE_MODE and restart workers
Worker pods use correct config
kubectl describe pod <worker> → env section
Redeploy with corrected Helm chart
Health endpoint reports correct mode
curl …/health/queue-mode
Restart n8n after fixing env vars
No stray .env files
git ls-files | grep .env
Remove or rename files on staging/production hosts
EEFA note: After any change, flush the old‑mode queue to avoid orphaned jobs.
# Example for Redis – delete keys from the dev namespace
redis-cli -n 0 KEYS "n8n:dev:*" | xargs -r redis-cli -n 0 DEL
Run this only during a maintenance window; deleting the wrong keys can lose in‑flight executions.
6. When to Use Explicit QUEUE_MODE Overrides
Scenario
Recommended Setting
Hybrid CI/CD pipelines where the same Docker image runs in both staging and prod
Set QUEUE_MODE via runtime overrides (docker run -e QUEUE_MODE=staging …) rather than baking it into the image.
Feature‑flag testing that needs a temporary dev queue in prod
Use QUEUE_MODE=developmentonly on a dedicated “sandbox” worker pool, isolated by a separate Redis DB (REDIS_URL=redis://redis-sandbox:6379).
Multi‑tenant SaaS with per‑tenant queue namespaces
Prefix the mode with tenant ID (QUEUE_MODE=production-tenant42). See the sibling page “n8n queue mode custom namespace” for implementation details.
Bottom Line
The “wrong environment mode” error is always a mis‑aligned QUEUE_MODE / NODE_ENV pair. Explicitly set both variables in your deployment manifest, verify with the health endpoint, and purge any stray queues before restarting. Following the checklist guarantees that each n8n instance processes only the jobs meant for its environment, preserving data integrity and operational stability.