A geolocation service shows a city that does not match the real address of the user or the server — one of the most common complaints to hosting support and one of the least alarming once you see how it actually works. A geoIP database does not work from a street address directly, but from a range of addresses owned by a provider or a data center.
How city detection by IP address works
An IPv4 address by itself carries no coordinates — it is a number that identifies a node on the network, and its structure is covered in the article on IPv4 addresses. Geolocation services match an address against a database where address ranges are tied to a provider's registration data — the company's legal address, not the physical location of a given user.
These databases are built from public registry records and from the geolocation services' own statistics, so accuracy depends on how consistently a provider keeps its addresses tied to one region.
Why a geoIP database gets the city wrong more often than the country
Large providers and data centers often register an address range under one legal address — for example, a head office in the capital — and hand it out to customers across the whole country. The database only sees the registration point, so the country is almost always detected correctly, while the city may point to the provider's office rather than the physical location of the server or user.
The same pattern shows up with mobile carriers: all the traffic from subscribers in one region can pass through a single node registered in a different city.
NAT and provider address pools
Carriers with a limited number of external addresses use NAT with a shared pool across many subscribers — the mechanism is covered in the article on NAT. In that case, the external address the site sees belongs not to a specific user but to the carrier's node, which can physically sit in a different city.
The same applies to a server: if it runs behind NAT inside cloud infrastructure, the external address is tied to the exit node, not to the rack where the hardware physically sits.
VPNs, proxies, and a CDN in front of the server
If a CDN or a tunnel sits in front of the site — for example, Cloudflare Tunnel — the external IP address that visitors and geolocation services see belongs to the CDN node, not to the hosting server. That is a normal part of the setup, not a configuration mistake.
On the user side the reason is similar — an active VPN or proxy replaces the visible address with the address of the VPN provider's server, which can sit in a different country, let alone a different city.
Comparing typical causes
| Cause | Who sees the "wrong" city | Can the site fix it |
|---|---|---|
| Range registered to the provider's office | both the visitor and the server | no, depends on the provider |
| Shared address pool at a mobile carrier | the visitor | no |
| VPN or proxy on the user's side | the visitor | no, it is the user's choice |
| CDN or tunnel in front of the server | the server | partly, via the real-IP header |
| Outdated geoIP database at the service | both the visitor and the server | no, depends on the geolocation service |
How to check and clarify the real city
If the mismatch gets in the way — for example, a geo-restricted service blocks access — the checking order is this:
- find out exactly which address an outside service sees — your own public IP can be obtained with an outbound request;
- check that address against at least two independent geolocation services — a mismatch between them points to an outdated database rather than a mistake on a specific site;
- check whether a VPN or proxy is active on the client side;
- if a CDN sits in front of the server, look at the header carrying the visitor's real IP instead of the CDN node's address;
- when an exact address is legally required, request the data from the provider directly instead of relying on geoIP.
curl ifconfig.me
curl ipinfo.io/json
dig +short myip.opendns.com @resolver1.opendns.com
Frequently asked questions
Why does my IP address show a different city when I have not moved?
Most often it is not about moving at all — the provider has registered its address range under its head office, which is physically located in a different city. A geolocation database only sees the address's registration point, not the place where your hardware stands.
Can a VPN be the reason for the wrong city?
Yes, and that is the most common reason on the user's side: an active VPN replaces the address sites see with the address of the VPN provider's server, which is usually located in a different region or even a different country.
Why does a hosted server show the data center's city instead of its own region?
Because the server's address is registered to the data center or cloud provider, and the geoIP database ties it to that company's legal address rather than to the physical rack holding the hardware — that is normal behavior, not a hosting mistake.
How can the visitor's real IP address be found if the site runs behind a CDN?
You need to read the X-Forwarded-For header or a similar one that the CDN adds to the request — it carries the real visitor's address rather than the address of the CDN node that accepted the connection. Reading that header correctly depends on the web server and the CDN in use.