You add express-rate-limit, test it locally, and everything works.
Then you deploy to Render, Railway, Fly.io, or behind Nginx.
Suddenly, one of two things happens:
Your logs show ERR_ERL_UNEXPECTED_X_FORWARDED_FOR.
Your rate limiter starts treating multiple users as the same client, causing everyone to share one request limit.
The problem is often your Express proxy configuration.
When Express cannot identify the original client IP correctly, an IP-based rate limiter can end up counting requests against the proxy's address instead.
Here's why it happens, how to configure it, and what to check before deploying the fix.
Why it happens
When your Express application sits behind a reverse proxy, it doesn't communicate directly with the original client.β¦