Express req.ip Property

Beginner
⏱️ 8 min read
📚 Updated: May 2026
🎯 4 Code Examples

What you’ll learn

  • How Express determines req.ip.
  • How to configure trust proxy correctly.
  • How req.ip and req.ips differ.
  • How to use IP data safely for logging and rate limiting.

Usage syntax

javascript
req.ip
req.ips
1

Read client IP in a route

javascript
app.get('/ip', function (req, res) {
  res.json({ ip: req.ip });
});
2

Use req.ips behind trusted proxy

javascript
app.set('trust proxy', true);

app.get('/audit', function (req, res) {
  res.json({
    clientIp: req.ip,
    forwardedChain: req.ips
  });
});

❓ FAQ

It returns the client IP address for the current request.
If your app is behind a reverse proxy and trust proxy is not configured, req.ip may show proxy addresses.
When enabled correctly, Express can use X-Forwarded-For to determine the original client IP.
req.ip is the selected client IP, while req.ips is the chain of forwarded IPs when trust proxy is enabled.
Forwarded headers can be spoofed unless your proxy and trust proxy settings are configured carefully.
Did you know?

req.ip reflects the remote address, and when trust proxy is enabled it can use forwarded client IP headers.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

4 people found this page helpful