custom domain
shizogrek
HOBBYOP

2 months ago

Subject: n8n + custom domain: ERR_ERL_UNEXPECTED_X_FORWARDED_FOR blocking webhooks

Hello Railway Support Team,

I’m running n8n (Docker image: n8nio/n8n) as a web service on Railway with a custom domain attached.

I’m encountering a reproducible issue where incoming webhooks (Telegram Trigger) never reach the application when a custom domain is used.

Issue description

For every incoming HTTP request (Telegram webhook), the service fails at the middleware level with the following error:

ValidationError: The 'X-Forwarded-For' header is invalid
code: ERR_ERL_UNEXPECTED_X_FORWARDED_FOR
(express-rate-limit)

As a result:

  • the webhook reaches Railway,

  • but does not reach n8n,

  • and no executions are created in n8n.

What has been verified

  • Custom domain is correctly attached and visible in Deployments

  • HTTPS / SSL is active

  • Service is online and publicly accessible

  • Port is properly exposed

  • Environment variables configured:

    • N8N_TRUST_PROXY=true

    • N8N_LISTEN_ADDRESS=0.0.0.0

    • N8N_DISABLE_RATE_LIMIT=true

    • PORT=5678, N8N_PORT=5678

  • Full redeploy performed

The error persists consistently.

Important observation

When using the default *.up.railway.app domain, webhooks work correctly.

The issue occurs only when a custom domain is used, which strongly suggests an issue with how X-Forwarded-For headers are handled by the Railway proxy for custom domains.

Questions

  1. Are there any known limitations or special behaviors of Railway proxy regarding X-Forwarded-For when using custom domains?

  2. Is it possible to:

    • normalize or correctly forward the X-Forwarded-For header, or

    • disable or adjust this behavior for backend services?

  3. Is there a recommended configuration for applications behind Railway proxy (Express / rate-limit) to avoid this error?

I can provide logs or reproduce the issue in a minimal test service if needed.

Thank you for your time and support.

Best regards,

$10 Bounty

1 Replies

phoenixauro
HOBBY

2 months ago

Try
N8N_RATE_LIMIT_WINDOW_MS=0
N8N_RATE_LIMIT_MAX=0

Also try
N8N_PROXY_HOPS=1
and keep increasing this value till it works, for example try
N8N_PROXY_HOPS=2 next.


Loading...