Skip to content
API Guides

Get the Client IP in Express, Then Geolocate and Risk-Score It

Express get client IP behind nginx: in our test trust proxy true returned a spoofed 1.2.3.4, while 1 returned the address nginx saw. Then we scored it.

ByGeoIPHub TeamPublishedReading time18 min read
A blue glass tag moves along a glass pipe through two shield-marked frosted gates to a magnifying lens, which splits into three branches ending in an open ring, a violet location pin and a padlock
JavaScript
import express from 'express'; const app = express(); app.set('trust proxy', 1); app.get('/', (req, res) => res.send(req.ip)); app.listen(3000);

That 1 assumes exactly one proxy in front that appends the address it saw.

On 30 November 2026 we ran Express 5.3.0 on Node 24.20.0 with six trust proxy settings and sent each the same requests. A spoofed X-Forwarded-For: 1.2.3.4 sent from a trusted peer (our curl on loopback) came back as req.ip under true, 1, 'loopback' and 2, while false and a subnet that did not contain the sender returned the real peer. When a proxy appended the real client (1.2.3.4, 203.0.113.9), true and 2 still returned 1.2.3.4, while 1 and 'loopback' returned 203.0.113.9.

Behind an nginx container at a private address that appended to the header, 'loopback' did not trust nginx and 'uniquelocal' returned the forged 1.2.3.4.

Below, for a Node.js app: the value per host with the quoted docs, a debug route, and a middleware that cleans the address, looks it up with GeoIPHub's API and branches on recommended_action. For why the left-most entry is forgeable, see which X-Forwarded-For IP to trust.

Why req.ip shows your proxy, and ::ffff:127.0.0.1 on localhost

With the default trust proxy of false, req.ip is the socket's remote address, so behind a proxy the visitors show up as the proxy. The Express behind-proxies guide, read 30 November 2026: "If false, the app is understood as directly facing the client and the client’s IP address is derived from req.socket.remoteAddress. This is the default setting." Everything keyed on req.ip then sees one address: one rate limit, one geolocation, one fraud score.

On localhost an IPv4 client reaching a server that listens on :: is shown as an IPv4-mapped address, and an IPv6 client as ::1. These are the false rows of cases A and B in our matrix:

Output
8101 {"trust_proxy":false,"ip":"::ffff:127.0.0.1","ips":[],"remoteAddress":"::ffff:127.0.0.1"} 8101 {"trust_proxy":false,"ip":"::1","ips":[],"remoteAddress":"::1"}

A plain app.listen(port) with no host gave the same on this machine (macOS, Node 24.20.0), and Express passed the prefix through under all six settings. Plain Node with no Express printed the same two values, so the prefix comes from the socket:

JavaScript
import http from 'node:http'; http.createServer((req, res) => res.end(req.socket.remoteAddress + '\n')).listen(8350);

What each trust proxy value returns for req.ip and req.ips

Each trust proxy value decides how far into X-Forwarded-For Express reads: the guide says req.ip and req.ips "are populated based on the socket address and X-Forwarded-For header, starting at the first untrusted address." The setting takes a boolean, a hop count, an address or subnet, a list of them, or a function. Three names stand for ranges: loopback is 127.0.0.1/8 and ::1/128, linklocal is 169.254.0.0/16 and fe80::/10, and uniquelocal is 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 and fc00::/7. We did not run the function form; Express issue 6541 reports its callback being called more than once per request.

We played the proxy ourselves: curl on loopback sends the header to a loopback peer. The server is one listener per setting:

JavaScript
import express from 'express'; const modes = { 8101: false, 8102: true, 8103: 1, 8104: 'loopback', 8105: 2, 8106: '10.0.0.0/8' }; for (const [port, tp] of Object.entries(modes)) { const app = express(); app.set('trust proxy', tp); app.get('/', (req, res) => res.json({ trust_proxy: tp, ip: req.ip, ips: req.ips, remoteAddress: req.socket.remoteAddress })); app.listen(Number(port), '::'); }

The traced request is case D, a spoofed value followed by the address a proxy at 127.0.0.1 would append:

Output
curl -s -H "X-Forwarded-For: 1.2.3.4, 203.0.113.9" http://127.0.0.1:8103/

1.2.3.4 is what the client typed and 203.0.113.9 is what our pretend proxy added. Express checks that the socket address is trusted, then reads the header from the right.

Glass tiles on a track between a client panel on the left and a blue cube on the right; three glowing blue tiles sit right of a frosted arch, one clear unlit tile just left of it, and three grey tiles behind that
Each trust proxy setting decides how far from the app Express keeps reading.

false, the default

  • With trust proxy false, req.ip was the socket address, ::ffff:127.0.0.1, and req.ips was empty (cases C and D).

true

  • With trust proxy true, req.ip was 1.2.3.4 in cases C and D, with req.ips of ["1.2.3.4","203.0.113.9"] in case D. The guide calls this the "left-most entry".
  • true trusts every sender, so a client that connects directly with a forged header gets the same result. The guide's warning: the last trusted proxy must be "removing/overwriting all of the following HTTP headers: X-Forwarded-For, X-Forwarded-Host, and X-Forwarded-Proto, otherwise it may be possible for the client to provide any value."

1

  • With trust proxy 1, req.ip was 203.0.113.9 in case D, the entry the pretend proxy appended, and 1.2.3.4 in case C, the nearest untrusted address.
  • A count trusts the nearest hops whoever sent them: from our machine's LAN address, a forged X-Forwarded-For: 1.2.3.4 sent straight to the app came back as req.ip under 1, 2 and true.

'loopback'

  • With trust proxy 'loopback', req.ip was 203.0.113.9 in case D and 1.2.3.4 in case C, because the sender, curl on loopback, is in a range it trusts.
  • From the LAN address with the same forged header, 'loopback' returned ::ffff:192.168.55.87, the real peer.

2

  • With trust proxy 2 and one proxy, req.ip was 1.2.3.4 in case D: a count of two trusts one hop too many.

'10.0.0.0/8', a subnet that does not contain the sender

  • With trust proxy '10.0.0.0/8', req.ip was ::ffff:127.0.0.1 in every header case (C to H): the sender was not trusted, so the header was not read.

Our judgment: set trust proxy to a fact about your network, not to true by habit, because in our test true returned the value the client typed. Prefer a list of your proxies' addresses over a hop count, and use 'loopback' only when the proxy reaches the app over loopback. The guide warns a count needs "not multiple, different-length paths to the Express application", and adds that enabling trust proxy makes req.hostname follow X-Forwarded-Host and req.protocol follow X-Forwarded-Proto, so a wrong value affects more than the IP.

req.ip against req.ips

req.ips lists the forwarded entries Express used, left to right, and in every row where it was not empty req.ip was its first element. Log both while you set this up.

Get the client IP in Express: which trust proxy value fits your host

The right Express trust proxy value names the proxies in front of your app, by address or by count, so it changes when someone adds a CDN. We read each page below on 30 November 2026 and sent no request through these hosts, so apart from our nginx run each value is our reading of the quoted text.

nginx

  • nginx's proxy module documentation says $proxy_add_x_forwarded_for is "the “X-Forwarded-For” client request header field with the $remote_addr variable appended to it, separated by a comma".
  • In our container run, nginx appended from a private, non-loopback address, and trust proxy 1 returned the address nginx saw, 172.29.0.1, while true and 'uniquelocal' returned the client-typed 1.2.3.4. With $remote_addr instead, all three returned 172.29.0.1.
  • For nginx, 'loopback' fits only when nginx reaches the app over loopback, as in our Express enforcement sample that trusts only loopback.

Heroku

  • Heroku's HTTP routing page ("Last updated August 24, 2026"): "If the Heroku router receives a request with the X-Forwarded-For header already present, the originating IP detected by the router is appended to the right-side of the list." It adds that X-Forwarded-* headers "are not trusted for security reasons".
  • For Heroku, our reading is app.set('trust proxy', 1) if the router is the only hop. Heroku names no Express value.

AWS Application Load Balancer

  • On AWS's X-Forwarded headers page, routing.http.xff_header_processing.mode is append by default, with preserve and remove as the others. AWS: "The entries can only be considered trustworthy if added by systems that are properly secured within the network."
  • For an AWS Application Load Balancer, our reading is app.set('trust proxy', 1) under append when the load balancer is the only hop. Under preserve the header is "not modified in any way", so a count would return a client-typed entry.

Fly.io

  • Fly.io's request headers page calls Fly-Client-IP "the IP address of the client from the perspective of Fly Proxy" and says X-Forwarded-For "must be treated with caution to avoid spoofing attempts". It does not say whether a client-sent X-Forwarded-For is removed, so we could not confirm a value for Fly.io; test it.

Render

  • We could not find Render's documentation of this. On Render, send a fake X-Forwarded-For to your service and read the debug route below rather than trust a number from a forum.

Cloudflare

  • For Cloudflare, give trust proxy loopback plus Cloudflare's published ranges, or read CF-Connecting-IP after checking the peer; the Cloudflare section below shows both.

Test your Express setup with a debug route and a forged X-Forwarded-For

Send one request with a forged X-Forwarded-For: 1.2.3.4 through your real proxy: a correct setup returns the client's address, not 1.2.3.4. This is the route we ran on 30 November 2026 at 05:31 UTC:

JavaScript
import express from 'express'; const modes = { 9001: false, 9002: true, 9003: 1, 9004: 'loopback', 9005: 'uniquelocal' }; for (const [port, tp] of Object.entries(modes)) { const app = express(); app.set('trust proxy', tp); app.get('/', (req, res) => res.json({ trust_proxy: tp, ip: req.ip, ips: req.ips, remoteAddress: req.socket.remoteAddress, xff_seen: req.headers['x-forwarded-for'] ?? null })); app.listen(Number(port)); }

The layout: Docker Desktop 4.90.0 (Docker Engine 29.7.2) on a Mac, a user-defined network (172.29.0.0/16, gateway 172.29.0.1), the app in node:24-bookworm-slim (Node v24.22.2, Express 5.3.0) at 172.29.0.2, and one nginx:1.27-alpine container per config at 172.29.0.3 and 172.29.0.4. curl on the Mac reached nginx through a published port. The two configs differ in one line:

Output
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $remote_addr;

Docker showed nginx the client as 172.29.0.1, the network gateway, a private address. With the first config (append) and a request carrying X-Forwarded-For: 1.2.3.4:

Output
true {"trust_proxy":true,"ip":"1.2.3.4","ips":["1.2.3.4","172.29.0.1"],"remoteAddress":"::ffff:172.29.0.3","xff_seen":"1.2.3.4, 172.29.0.1"} 1 {"trust_proxy":1,"ip":"172.29.0.1","ips":["172.29.0.1"],"remoteAddress":"::ffff:172.29.0.3","xff_seen":"1.2.3.4, 172.29.0.1"} loopback {"trust_proxy":"loopback","ip":"::ffff:172.29.0.3","ips":[],"remoteAddress":"::ffff:172.29.0.3","xff_seen":"1.2.3.4, 172.29.0.1"} uniquelocal {"trust_proxy":"uniquelocal","ip":"1.2.3.4","ips":["1.2.3.4","172.29.0.1"],"remoteAddress":"::ffff:172.29.0.3","xff_seen":"1.2.3.4, 172.29.0.1"}
  • 'loopback' returned nginx's address, because nginx was not on loopback: the symptom from the top of this post, from a correct-looking setting.
  • true returned the forged 1.2.3.4, because nginx appended instead of replacing.
  • 'uniquelocal' also returned 1.2.3.4: it trusted nginx and then 172.29.0.1, both private, and stopped at the typed entry. We did not test a public client address.

With the second config, $remote_addr, the same forged request returned 172.29.0.1 under true, 1 and 'uniquelocal', and nginx's own address under false and 'loopback'. Overwriting removes the client's entry before Express sees it, the condition the guide sets for true.

Clean req.ip before you use it: ::ffff: prefix, ports and junk

Express does not validate req.ip: it returns the text the header held, so in our matrix a mapped address (case F), a port (case G) and not-an-ip (case H) came back unchanged under true, 1, 'loopback' and 2:

Output
8102 {"trust_proxy":true,"ip":"::ffff:203.0.113.9","ips":["::ffff:203.0.113.9"],"remoteAddress":"::ffff:127.0.0.1"} 8102 {"trust_proxy":true,"ip":"203.0.113.9:4711","ips":["203.0.113.9:4711"],"remoteAddress":"::ffff:127.0.0.1"} 8102 {"trust_proxy":true,"ip":"not-an-ip","ips":["not-an-ip"],"remoteAddress":"::ffff:127.0.0.1"}

Treat req.ip as untrusted text until net.isIP says it is an address. This helper, saved as clean-ip.mjs, strips brackets and a trailing port, turns an IPv4-mapped address back into IPv4, and returns null for anything else:

JavaScript
import { isIP } from 'node:net'; export function cleanIp(raw) { if (typeof raw !== 'string') return null; let s = raw.trim(); const bracketed = s.match(/^\[([^\]]+)\](?::\d+)?$/); if (bracketed) s = bracketed[1]; else if (/^[^:]+:\d+$/.test(s)) s = s.slice(0, s.lastIndexOf(':')); if (s.toLowerCase().startsWith('::ffff:') && isIP(s.slice(7)) === 4) s = s.slice(7); return isIP(s) ? s : null; }
Output
"::ffff:203.0.113.9" gives "203.0.113.9" "203.0.113.9:4711" gives "203.0.113.9" "[2001:db8::1]:8080" gives "2001:db8::1" "[2001:db8::1]" gives "2001:db8::1" "not-an-ip" gives null "::1" gives "::1" "2001:db8::1" gives "2001:db8::1" "::ffff:127.0.0.1" gives "127.0.0.1" "203.0.113.9" gives "203.0.113.9"

AWS documents the port shape: with routing.http.xff_client_port.enabled the header includes the client port after a colon, and an IPv6 address is enclosed in square brackets. The lookup is the reason to clean: on 25 November 2026 GeoIPHub's API answered HTTP 400 for 203.0.113.7:8080, [2001:db8::1] and unknown; the evidence and a longer normalizer are in the X-Forwarded-For guide.

Express behind Cloudflare: trust its ranges, or read CF-Connecting-IP after checking the peer

By default Cloudflare appends to a client-sent X-Forwarded-For. Cloudflare's HTTP headers page ("Last updated Nov 15, 2026" when we opened it on 30 November) says that when the header is already present, "Cloudflare will append the IP address of the HTTP proxy connecting to Cloudflare to the header." It recommends CF-Connecting-IP (or True-Client-IP on Enterprise plans) over X-Forwarded-For for the single address; the Pseudo IPv4 exception is in the X-Forwarded-For guide.

To walk past Cloudflare, give trust proxy a list: loopback plus Cloudflare's published ranges. Save https://www.cloudflare.com/ips-v4 and https://www.cloudflare.com/ips-v6 as cloudflare-ips-v4.txt and cloudflare-ips-v6.txt next to the app, one range per line. We fetched both on 30 November 2026 at 05:31 UTC and got 15 and 7 ranges, the same as on 25 November. We cannot connect from Cloudflare's addresses, so our loopback curl stood in for an edge address:

JavaScript
import express from 'express'; import { readFileSync } from 'node:fs'; const ranges = ['cloudflare-ips-v4.txt', 'cloudflare-ips-v6.txt'].flatMap((f) => readFileSync(new URL(f, import.meta.url), 'utf8').split('\n').map((l) => l.trim()).filter(Boolean)); const app = express(); app.set('trust proxy', ['loopback', ...ranges]); app.get('/', (req, res) => res.json({ ip: req.ip, ips: req.ips })); app.listen(3000);

With X-Forwarded-For: 203.0.113.9, 173.245.48.5, where the second entry is inside 173.245.48.0/20, Express returned 203.0.113.9 with req.ips of ["203.0.113.9","173.245.48.5"]: the Cloudflare address was skipped.

Express did not read CF-Connecting-IP for us. With trust proxy true, CF-Connecting-IP: 203.0.113.50, X-Real-IP: 203.0.113.51 and no X-Forwarded-For, req.ip was ::ffff:127.0.0.1. If you read CF-Connecting-IP yourself, check that the connection came from Cloudflare's ranges first. That is needed but not enough, because another account's Worker can set the header from inside those ranges; the fixes are in the X-Forwarded-For guide. Refresh the ranges at deploy or on a timer, not per request.

Look up the client IP from an Express middleware

This middleware sends the cleaned req.ip to GET https://api.geoiphub.com/v1/lookup/{ip} and attaches the result as req.geoip. It skips private and invalid addresses, times out at 1.5 seconds (our choice, not an API figure), sends x-api-key only when GEOIPHUB_KEY is set, and catches lookup errors so the request carries on. Save it as geoip.mjs, next to clean-ip.mjs:

JavaScript
import { BlockList, isIP } from 'node:net'; import { cleanIp } from './clean-ip.mjs'; const nonPublic = new BlockList(); for (const [net, bits] of [['10.0.0.0', 8], ['127.0.0.0', 8], ['169.254.0.0', 16], ['172.16.0.0', 12], ['192.168.0.0', 16]]) nonPublic.addSubnet(net, bits, 'ipv4'); for (const [net, bits] of [['::1', 128], ['fc00::', 7], ['fe80::', 10]]) nonPublic.addSubnet(net, bits, 'ipv6'); export async function geoip(req, res, next) { req.clientIp = cleanIp(req.ip); req.geoip = null; if (!req.clientIp || nonPublic.check(req.clientIp, isIP(req.clientIp) === 4 ? 'ipv4' : 'ipv6')) return next(); const headers = process.env.GEOIPHUB_KEY ? { 'x-api-key': process.env.GEOIPHUB_KEY } : {}; try { const r = await fetch(`https://api.geoiphub.com/v1/lookup/${req.clientIp}`, { headers, signal: AbortSignal.timeout(1500) }); if (r.status === 200) req.geoip = await r.json(); } catch {} next(); }

We ran it keyless in the app shown in the next section, with curl on loopback playing the proxy. At 05:32:57 UTC on 30 November 2026 a keyless lookup of 8.8.8.8 returned HTTP 200 with x-ratelimit-limit: 30; trimmed, with nesting and values as returned:

JSON
{ "ip": "8.8.8.8", "asn": { "org": "GOOGLE - Google LLC" }, "geo": { "country_code": "US" }, "detection": { "is_hosting": true, "is_vpn": false, "is_tor": false }, "scoring": { "fraud_score": 10, "recommended_action": "allow" } }

A free plan key gives 1,500 lookups a day with every field. For the one-hour cache and the daily budget, use that post's code. The request format is in the API reference.

Each of the four recommended_action values maps to one Express response here: allow calls next(), review sets a flag for logging or a queue, step_up returns a 401 telling the client to verify, block returns a 403. The mapping is our design, not API behaviour. Add these two functions to geoip.mjs:

JavaScript
export function failClosed(req, res, next) { if (!req.geoip) return res.status(503).json({ error: 'verification unavailable' }); next(); } export function branch(req, res, next) { const action = req.geoip?.scoring?.recommended_action; if (action === 'block') return res.status(403).json({ error: 'blocked' }); if (action === 'step_up') return res.status(401).json({ error: 'verify first', challenge: '/verify' }); req.flagged = action === 'review'; next(); }

The app that ran them, with trust proxy 'loopback' because our curl on loopback played the proxy:

JavaScript
import express from 'express'; import { geoip, failClosed, branch } from './geoip.mjs'; const app = express(); app.set('trust proxy', 'loopback'); app.use(geoip); const summary = (req) => ({ ip: req.clientIp, country: req.geoip?.geo?.country_code, org: req.geoip?.asn?.org, is_hosting: req.geoip?.detection?.is_hosting, fraud_score: req.geoip?.scoring?.fraud_score, action: req.geoip?.scoring?.recommended_action, flagged: req.flagged === true, }); app.post('/signup', branch, (req, res) => res.json(summary(req))); app.post('/checkout', failClosed, branch, (req, res) => res.json(summary(req))); app.listen(3000);

The lookup fails open: on a timeout or error req.geoip stays null and the request carries on, which suits a page view. Checkout adds failClosed, because a payment is where we would rather refuse than guess. The signup route ran its keyless lookups between 05:32:53 and 05:32:55 UTC on 30 November 2026. A separate keyless call to each address at 05:32:57 to 05:32:58 UTC returned HTTP 200, and the score, action and flags below are from those calls:

8.8.8.8, Google Public DNS

  • The route returned HTTP 200 with {"ip":"8.8.8.8","country":"US","org":"GOOGLE - Google LLC","is_hosting":true,"fraud_score":10,"action":"allow","flagged":false} (the printed code, re-run at 05:59:41 UTC).

185.213.155.73, a VPN server on 31173 Services AB (is_vpn true)

  • Score 70, step_up, country DE. The route returned HTTP 401 with {"error":"verify first","challenge":"/verify"}.

185.220.101.1, a Tor exit (is_tor true)

  • Score 100, block, country DE. The route returned HTTP 403 with {"error":"blocked"}.

None of the 18 sample addresses we probed that day landed in review, so that branch was not exercised live. 8.8.8.8:4711 in the header was cleaned and looked up as 8.8.8.8; not-an-ip gave "ip":null with no lookup; a request with no header was skipped as private and got HTTP 503 on checkout.

When we re-ran the printed code at 05:56:15 UTC, the Tor exit's lookup returned no result and signup let it through with HTTP 200, {"ip":"185.220.101.1","flagged":false}. We did not log whether the timeout or an error caused it; five direct calls a minute later took 489 to 809 ms. Put failClosed on any route where a missed Tor exit costs more than a refused user.

A 403 is hard to undo for a real person on a shared address, so the example answers a VPN with a challenge; a lookup describes a network, not the user. Take cutoffs per route from the thresholds post, not from this example.

Rate limiting by req.ip: why express-rate-limit complains

express-rate-limit keys on req.ip, so a wrong trust proxy can put all visitors in one bucket or let a client pick its own. We ran express-rate-limit 8.7.5 on three listeners and sent X-Forwarded-For: 198.51.100.23 to each. With trust proxy false, the default, it logged ERR_ERL_UNEXPECTED_X_FORWARDED_FOR:

Output
ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users. See https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/ for more information.

With true it logged ERR_ERL_PERMISSIVE_TRUST_PROXY:

Output
ValidationError: The Express 'trust proxy' setting is true, which allows anyone to trivially bypass IP-based rate limiting. See https://express-rate-limit.github.io/ERR_ERL_PERMISSIVE_TRUST_PROXY/ for more information.

With 'loopback' it logged neither. The error codes page, read on 30 November 2026, says that with true "it will cause express to return the leftmost entry in the X-Forwarded-For header as the client’s IP." IPv6 clients need keys that group by prefix; see prefix-aware keys.

What this setup does not cover

We ran Express 5.3.0 on one Mac and in one container on Docker Desktop, which can present the client differently from a Linux host. We did not trace a request through real Cloudflare, ALB, Heroku, Render or Fly, or test Express 4, NestJS, Fastify, Docker Swarm or Kubernetes ingress.

  • A directly reachable origin defeats any forwarded header. If the app answers the internet directly, no trust proxy value fixes it; lock the network first.
  • The first untrusted address may not be the person. It can be a corporate or third-party proxy, and a high score on a shared or carrier address can punish real people.
  • Next.js and PHP have their own answers, which we did not test here.

To start, copy the debug route into your app, send it a forged X-Forwarded-For through your real proxy, and once req.ip is the real client, send the cleaned address to the keyless endpoint https://api.geoiphub.com/v1/lookup/{ip}.

Frequently Asked Questions

How do I get the client IP in Express?

Read req.ip, after setting app.set('trust proxy', ...) to your own proxies. The default false returns the socket address, which behind a proxy is the proxy (Express 5.3.0, 30 November 2026).

Is req.ip safe to trust?

Only as far as trust proxy is right. A spoofed X-Forwarded-For: 1.2.3.4 from a trusted peer came back as req.ip under true, 1, 'loopback' and 2, and a port or not-an-ip came back unchanged, so validate it before a lookup such as GeoIPHub's API.

Why is req.ip ::ffff:127.0.0.1?

An IPv4 client on a server that accepts IPv6 connections is shown as an IPv4-mapped address. Express returned it under all six settings on our machine, so remove the prefix yourself.

Should I use trust proxy true or 1?

Neither by habit. In our proxy-appended test true returned 1.2.3.4 and 1 returned 203.0.113.9, the address the proxy added. A count breaks when the path changes, so list your proxies when you can.

Does Express read CF-Connecting-IP or X-Real-IP?

Not in our run. With trust proxy true and both headers sent without an X-Forwarded-For, req.ip was the socket address. Read CF-Connecting-IP yourself, after you have checked that the connection came from Cloudflare.

What do ERR_ERL_UNEXPECTED_X_FORWARDED_FOR and ERR_ERL_PERMISSIVE_TRUST_PROXY mean?

ERR_ERL_UNEXPECTED_X_FORWARDED_FOR is logged when X-Forwarded-For is set while trust proxy is false, and ERR_ERL_PERMISSIVE_TRUST_PROXY when it is true (express-rate-limit error codes page, read 30 November 2026).

Which IP should I send to GeoIPHub?

The cleaned address, without a port or brackets. GeoIPHub's API answered HTTP 400 to 203.0.113.7:8080, [2001:db8::1] and unknown on 25 November 2026, and it does not guess the caller's address.

Written by

GeoIPHub Team

The team behind the GeoIPHub API

Written by the GeoIPHub team, the people who build the GeoIPHub IP intelligence API and its scanner. Drafts are prepared with AI assistance and edited by the team; API examples are real lookups against the live API unless labelled illustrative.

Share this article
More articles

Related posts