In Express.js, req.ip is the remote IP address of the request. By default it comes from the connection socket (for example 127.0.0.1 on localhost).
When trust proxy is enabled, Express derives req.ip from the left-most entry in X-Forwarded-For. That header can be set by a proxy or by a client — configure trust carefully. This is a server-side property on the request object.
Syntax
Read req.ip in your Express.js route handler. Start with this line.
Express
req.ip
Call
What it does
req.ip
Primary signature.
Install with npm install express. Create the app with const app = express() before you use this API in an Express.js tutorial project.
Proxy sits in front. The socket address is often the proxy, not the browser.
Enable trust for that hop. Express then reads X-Forwarded-For.
Left-most is the client. Official rule: first address in the list becomes req.ip.
Use req.ips for the chain. Helpful when debugging multiple proxies.
Compatibility
Runtime Support
req.ip is an Express.js request property. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not expose this value to page scripts.
✓ Server · Express 4 & 5
req.ip
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers. Not available in the browser.
ServerNode.js runtime API
Node.js18+ for Express 5 · 14+ typical for Express 4
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
req.ipExpress on Node.js
Bottom line: Configure trust proxy only when you are behind a real proxy, then read req.ip for the client address.
Frequently Asked Questions
It is the remote IP address for the request. By default it comes from the socket. With trust proxy enabled, Express uses the left-most address in X-Forwarded-For.
Your app is behind a reverse proxy and trust proxy is still false (the default). Configure trust proxy to match that proxy so forwarded headers are used.
req.ip is one selected client IP. req.ips is the full X-Forwarded-For chain as an array when trust proxy is on; otherwise it is [].
Yes if you trust X-Forwarded-For from untrusted clients. Only enable trust proxy for proxies you control, and have them overwrite spoofed forwarded headers.
The header is client, proxy1, proxy2. Express takes the left-most entry as req.ip when trust proxy is enabled — that is usually the original client.