How a Website Can Guess Your City Without Asking
You never told that shopping site where you live, yet it greets you with local prices. The answer is your IP address, a set of commercial maps of the internet and a farm in Kansas that learned how wrong those maps can be.
In this story 4 sections
Open a website for the first time and there is a good chance it already has a rough idea of where you are. Maybe it shows prices in your currency, a weather widget for your area or a list of stores nearby. You did not type your city. The site worked it out, usually without your browser asking for permission at all.
It starts with your IP address
Every connection to a website comes from an IP address, the number the internet uses to send replies back to you. Those numbers are not handed out at random. Blocks of addresses are allocated by five regional internet registries, covering North America, Europe and the Middle East, Asia-Pacific, Latin America and Africa, to internet providers and organisations, which then assign them to their customers.
Because addresses come in blocks tied to specific providers and regions, an address says something about where a connection probably comes from. Companies build geolocation databases that map ranges of addresses to countries, regions and cities, combining registry records, information from providers, network measurements and other data sources. A website looks up your address in one of these databases and gets a best guess.
Why the guess is often off
At the country level these databases are usually right. At the city level they are much shakier. Your address might be registered to your provider's office in a bigger city nearby, so the database puts you there. Mobile networks often route traffic through a regional gateway, which is why your phone can appear to be in a different city from the one you are standing in. A VPN goes further still: sites see the VPN server's address, so you appear wherever that server is.
| Situation | What the site sees | Typical accuracy |
|---|---|---|
| Home broadband | Your provider's address block | Country usually right; city sometimes off |
| Mobile data | Your carrier's gateway | Can be a different city or region |
| VPN | The VPN server's address | Wherever the server is |
| Browser location (with permission) | GPS, Wi-Fi or cell data | Often precise, but only if you allow it |
The farm in the middle of America
Sometimes a database knows only the country an address belongs to. It still has to give a pair of coordinates, so it uses a default point. In 2016, journalist Kashmir Hill reported that a widely used database had placed hundreds of millions of US IP addresses it could not locate more precisely at a single default point near the geographic centre of the country, which happened to be a farm in Kansas. For years the people living there received visits and complaints from strangers convinced that a scammer or a stolen device was on their property. After the story ran, the company moved its default point to the middle of a nearby lake.
A location database never says I don't know. It gives you coordinates, and coordinates look like facts.
What a site can and can't learn this way
IP geolocation gives a rough area, not your street address. Precise location needs your device's GPS or Wi-Fi positioning, and browsers ask for permission before sharing that.
What you can do about it
If a site keeps getting your location wrong, there is usually a setting to choose your region by hand. If you would rather sites did not know your rough area at all, a VPN changes the address they see, with the trade-offs of trusting the VPN provider instead. And it is worth remembering the lesson of the Kansas farm: an IP address is a clue, not an identity, and a pin on a map is only as good as the guess behind it.
In this story 4 sections
Keep Reading
All storiesThe Odd List · Fridays