Why is my 'What is my IP Address' tool showing incorrect public IP for some users?

Author
Camila Gonzalez Author
|
4 weeks ago Asked
|
86 Views
|
2 Replies
0

hey everyone, so we have this simple web tool, 'What is my IP Address', and it's been pretty stable for a while. but lately, we're seeing some really weird behavior.

the problem is that for a small percentage of users, our tool is returning an incorrect public IP address. instead of their actual home or office IP, it sometimes shows a datacenter IP, or an IP from a completely different region. it's really messing with user trust, and making our client IP detection look unreliable.

we're using a pretty standard request.ip type method in our backend, and it usually works fine. but for these specific cases, it's like the proxy chain or something is getting confused, which impacts the accuracy of our client IP detection.

here's what we sometimes see in our internal logs when this happens, showing an unexpected public IP:

[2023-10-26 14:35:01] INFO: User 123.45.67.89 (Expected: Home ISP) detected as 104.28.X.X (Cloudflare CDN)
[2023-10-26 14:35:02] WARN: Geo-IP mismatch for session XYZ. Reported IP: 172.217.Y.Y (Google Datacenter), Client IP: 203.0.113.Z (Unknown)

has anyone else faced issues with accurate public IP detection, especially with users behind VPNs, specific ISPs, or perhaps even certain mobile networks? are there better ways to ensure we're getting the true client IP? help a brother out please...

2 Answers

0
Henry Miller
Answered 3 weeks ago
Hello Camila Gonzalez,
"we're seeing some really weird behavior."
I've dealt with this exact challenge in tracking user origins; it's incredibly frustrating when client IP detection accuracy is compromised. The issue likely stems from your `request.ip` method retrieving the IP of an upstream proxy (like a CDN, VPN, or mobile carrier's CGNAT) rather than the true client. For more reliable IP geolocation, always prioritize parsing `X-Forwarded-For` or `X-Real-IP` headers, which are typically passed down the proxy chain. Are you currently logging and evaluating those headers in your backend?
0
Camila Gonzalez
Answered 3 weeks ago

Oh wow, thanks Henry, I hadn't even considered those headers in that context!

Your Answer

You must Log In to post an answer and earn reputation.