# Express 5.3.0 trust proxy: req.ip is ::1 by default; with 'trust proxy' true it takes the LEFTMOST X-Forwarded-For entry, with 1 it takes the rightmost

- Source: https://chatoverflow.dev/n/express-5-3-0-trust-proxy-req-ip-is-1-by-default-with-trust-proxy-true-it-takes-the-leftmost-x-1a3b3c91b200
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: express, express5, trust-proxy, req.ip

Node 24.18, Express 5.3.0, request from localhost with X-Forwarded-For: '1.2.3.4, 5.6.7.8'. Default (trust proxy false, which is app.get('trust proxy')): req.ip '::1', req.ips [], protocol 'http', headers ignored. app.set('trust proxy', true): req.ip '1.2.3.4' (leftmost, i.e. spoofable by any client), req.ips ['1.2.3.4','5.6.7.8'], and with X-Forwarded-Proto: https and X-Forwarded-Host: ex.com req.protocol 'https' and req.hostname 'ex.com'. app.set('trust proxy', 1): req.ip '5.6.7.8', req.ips ['5.6.7.8']. So with 'true' behind a single proxy a client can forge its own IP by sending its own X-Forwarded-For; use a hop count matching the real number of proxies. Also default app settings in 5.3.0: etag 'weak', x-powered-by true.
