n8n-io/n8n · warning
Bad Gateway
Error message
Bad Gateway
What it means
The telemetry/source-config controller proxies requests to api-rs.n8n.io. The http-proxy 'error' callback writes a raw 502 response with body 'Bad Gateway' whenever the proxy itself fails to reach the upstream (before any HTTP response is received).
Source
Thrown at packages/cli/src/controllers/telemetry.controller.ts:44
return;
},
proxyRes: (proxyRes) => {
// MCP app UIs call this cross-origin from sandboxed iframes. Upstream
// may set CORS headers too, so normalize to one permissive value.
for (const header of [
'access-control-allow-origin',
'access-control-allow-credentials',
'access-control-allow-methods',
'access-control-allow-headers',
'access-control-expose-headers',
]) {
delete proxyRes.headers[header];
}
proxyRes.headers['access-control-allow-origin'] = '*';
},
error: (_error, _req, res) => {
if ('writeHead' in res && !res.headersSent) {
res.writeHead(502, { 'Access-Control-Allow-Origin': '*' });
res.end('Bad Gateway');
}
},
},
});
}
private applyCors(req: AuthenticatedRequest, res: Response) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
const requestedHeaders = req.headers['access-control-request-headers'];
res.setHeader(
'Access-Control-Allow-Headers',
typeof requestedHeaders === 'string' && requestedHeaders.length > 0
? requestedHeaders
: 'Content-Type, Authorization, anonymousId',
);View on GitHub (pinned to 5ac6606e81)
Solutions
- Allow outbound HTTPS to api-rs.n8n.io (and the RudderStack data plane) in firewall/egress rules.
- If the instance is offline, disable diagnostics (N8N_DIAGNOSTICS_ENABLED=false) so the proxy is not exercised.
- Route n8n through a corporate forward proxy (HTTP_PROXY/HTTPS_PROXY) if direct egress is blocked.
Example fix
// before: offline/air-gapped instance still trying to proxy -> 502 Bad Gateway // after: disable diagnostics for offline instances // .env N8N_DIAGNOSTICS_ENABLED=false
Defensive patterns
Strategy: fallback
Validate before calling
// Skip telemetry calls on offline instances.
function shouldProxyTelemetry(env = process.env) {
return String(env.N8N_DIAGNOSTICS_ENABLED).toLowerCase() !== 'false';
} Try / catch
// The 502 is a raw response, not a thrown JS error. Handle at the HTTP layer.
if (res.status === 502 && res.body === 'Bad Gateway') {
// degrade telemetry silently; do not block the UI
} Prevention
- Disable diagnostics on air-gapped instances.
- Permit egress to api-rs.n8n.io or configure a forward proxy.
When it happens
Trigger: Any proxied telemetry/source-config request where the proxy emits an error event — upstream unreachable, DNS failure, connection reset, TLS handshake failure — and res.headersSent is still false.
Common situations: Air-gapped/offline instance; firewall/egress rules block outbound to api-rs.n8n.io; DNS misconfiguration; corporate proxy not configured for n8n.
Understand the failure class
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
Related errors
- Failed to fetch source config: ${response.statusMessage}
- Failed to fetch provider catalog: ${response.statusText}
- OpenTelemetry active span callback is required.
- Telemetry tracer must implement startSpan() and startActiveS
- Cannot set both .tracer() and .otlpEndpoint() — use one or t
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/01fe99c657be08ac.
Report an issue: GitHub.