Finding external IP address of Photon

I have a Photon application for a clock, which uses the external IP address to ascertain the timezone the Photon is located in. By external, I mean the IP address provided by the ISP, outside the local router, not the one provided to the device by the DHCP server in the router. The app uses a web service ( to find this out. Most of the time it works correctly, but periodically it returns an IP address of, in San Jose. At the moment this happens, if I do the same query from my PC, I get my correct (Comcast in Massachusetts) IP address. Does Particle route Photon TCP client requests through its own servers? Is there some other explanation for this behavior?

Hi @davidcane

Particle does not route your TCP requests at all, but your ISP Comcast does. I think this is mostly likely a problem in or at Comcast. I can’t think of anyway your code could make this happen.

Thanks for the prompt response. I’m still a little baffled by the fact that at a time when my Photon gets the wrong response from, my PC, sharing the same router and same ISP connection, gets the correct response with the identical query.

Here’s a link to a Techdirt article from 2016 about how awful these services are:

I get that the geolocation tools suffer from GIGO and are not inherently reliable. My problem was that the IP address was wrong, and that is not a database issue.

I’m wondering if this technique might not be part of the answer:

At that location we will find that we can set up a subscription for a “special” topic called:


and then when we publish on that topic we get our public IP as a response. When I tried this, what I got was my external (Internet) based IP address. My gut/guess says that this works by publishing a message that is received by the particle cloud. The cloud must have an IP address that can be used to reach-back to the device and this is what I think is returned.


I have done some testing on a variety of sites and discovered, to my surprise, that returns the incorrect IP address about 20% of the time. So that was my problem. seems to do much better.

Thank you, this works quite well. I still need to use a geo location web site to go from the IP address to the timezone, and all of the sites that do geo location also provide IP lookup.

Out of curiosity, if your device is online and therefore connected to WiFi why not use this which works remarkably well assuming your SSID’s aren’t super secret and unknown to Googles prying eyes and roaming cars.

If you have coordinates, through Google Geolocation or just manually entered, you can use Googles Timezone API to get the current timezone for a geographical location as well as the DST offset.