My public IP tool broken!
i'm totally stuck, my simple 'what is my public IP address' tool is returning empty or incorrect data and i've tried everything. i'm seriously pulling my hair out trying to figure out what's wrong with this IP address lookup service.
it's a super basic tool, just fetches the user's public IP using various external APIs. it was working fine for months, perfectly stable, but suddenly started acting up in the last 24 hours. i need to fix this asap because it's a core feature for many of my users.
i've attempted a bunch of things:
- checked server logs, but honestly, nothing obvious jumped out at me. no big red errors, just some usual noise.
- restarted the server a few times, hoping it was just a temporary glitch. no luck.
- tried different IP lookup APIs (like ipify, ip-api.com, seeip.org) โ same issue across the board, or just really inconsistent results where sometimes it works for a second then fails again.
- double-checked firewall rules and security groups on my AWS instance. everything looks open for outbound HTTPS traffic, which is what these APIs use.
- ran
curlcommands directly from the server's terminal to these very APIs, and guess what? they return the correct public IPs there! but my app, when running, just doesn't show it.
the specific error/symptoms are frustratingly vague. instead of displaying the actual public IP, users are seeing either a completely blank field, or sometimes a local IP like 192.168.x.x or 172.x.x.x, which is definitely not the public IP. when i try to debug the code, the variable holding the IP is often empty or null. sometimes i even see a timeout error pop up in my own internal logging, like the request isn't even making it out properly or the response is getting lost somewhere.
here's a dummy console output that kinda shows what i'm seeing when i try to log the response:
// Inside my Node.js app (example)
axios.get('https://api.ipify.org?format=json')
.then(response => {
console.log('API Response:', response.data);
// Expected: { "ip": "1.2.3.4" }
// Actual: API Response: {} or sometimes even just a timeout
})
.catch(error => {
console.error('IP API Error:', error.message);
// Often getting: IP API Error: timeout of 5000ms exceeded
// Or: IP API Error: Network Error
});
// Sometimes, if it "works" but fetches wrong IP (from a proxy or internal network)
// API Response: { "ip": "192.168.1.100" }
i'm desperate for help. has anyone experienced this with their IP detection tools or similar web services? any ideas what could be causing this sudden failure? it's driving me nuts.
2 Answers
MD Alamgir Hossain Nahid
Answered 1 week agoYour issue, particularly the discrepancy between curl from the server and your application's behavior, strongly indicates an internal proxy server configuration or network configuration problem within your application's runtime environment. Investigate environment variables like HTTP_PROXY or HTTPS_PROXY, or application-specific proxy settings in your Node.js code (e.g., Axios proxy option) that might be routing requests through an internal network or a misconfigured proxy, causing the public IP address lookup service to fail or return local IPs.
Amelia Davis
Answered 1 week agoOMG that was it! The proxy variable was set incorrectly, public IPs are showing up now, massive relief. But weirdly, some of the other specific geo IP APIs I use are still timing out a lot, even though the main IP lookup works fast now...