Skip to content
Back to Blog
NetworkMarch 18, 2026·10 min read

IP Geolocation: How It Works and Its Accuracy Limits

IP geolocation maps IP addresses to physical locations. Learn the technology, accuracy, databases, and privacy implications.

Server rack representing IP geolocation infrastructure
privacy regulations, and never treat IP coordinates as precise physical locations.

and postal code levels. Always layer multiple data sources, keep databases updated, respect

IP geolocation delivers reliable country-level accuracy (~99%) but degrades rapidly at city

🌍 Geo Checker — Verify geographic location data for IP addresses in bulk.

🔍 IP Address Lookup — Resolve any IP to its geolocation, ISP, and ASN.

Tools

🚀 Free ToolZilla tools used in this article

All client-side, no signup, no upload — open them in a new tab while you read:

  • Using geolocation for fraud detection alone: Combine with device fingerprinting and behavioral signals.
  • Stale databases: IP reallocations happen constantly; outdated data degrades fast.
  • Ignoring IPv6: Many databases have weaker IPv6 coverage — test both protocols.
  • Blocking users by country without appeal: CGNAT and VPNs cause false positives in geo-blocking.
  • Trusting coordinates as exact: The lat/lng is typically a city centroid, not a street address.
    • Common Mistakes

  • Implement fallback logic for unresolvable IPs (private ranges, CGNAT).
  • Update your local database at least biweekly to keep accuracy current.
  • Use the GeoLite2 free database locally before paying for API calls.
  • Combine IP geolocation with user-selected locale for content personalization.
  • Always validate country-level data before trusting city-level results.
    • (weekly at most). This reduces API costs and latency.

      Cache geolocation results aggressively — IP-to-location mappings change infrequently

      Best Practices

    • Right to object: Allow users to opt out of location-based personalization.
    • Transparency: Disclose IP-based geolocation in your privacy policy.
    • Retention limits: Delete raw IP logs within a defined retention period.
    • Data minimization: Store only country/region if city-level precision isn't required.
    • Legal basis: Use legitimate interest (Art. 6(1)(f)) or consent for geolocation processing.
      • Key compliance points: Under GDPR, an IP address is considered personal data when it can be linked to an individual.

        Privacy & GDPR Considerations

      in client-side JavaScript.

      💡 Always keep API tokens in environment variables or a secrets manager — never hardcode them

      geolocate('8.8.8.8').then(console.log);// Usage} }; org: data.org, // ASN + ISP name loc: data.loc, // "lat,lng" country: data.country, region: data.region, city: data.city, return { const data = await res.json(); if (!res.ok) throw new Error(`HTTP ${res.status}`); const res = await fetch(`https://ipinfo.io/${ip}/json?token=${token}`); const token = 'YOUR_IPINFO_TOKEN';async function geolocate(ip) {
      // Fetch geolocation for a given IP

      A minimal example querying IPinfo's API:

      API Example: JavaScript Fetch

      real local IP or timezone, creating a discrepancy with the stated IP location.

      4. WebRTC & Timezone Fingerprinting
      Browser APIs can reveal the

      location than their IP, the mismatch indicates proxying.

      3. DNS Leak Checks
      If a user's DNS queries originate from a different

      port scanning signatures, and high connection rates flag anonymizers.

      2. Behavioral Heuristics
      Datacenter ASNs rather than residential ISPs,

      proxy lists, and Tor exit nodes (published by the Tor Project).

      1. Known IP Lists
      Maintain databases of VPN provider IP ranges, public

      node — not the user. Detection strategies include: When users route traffic through VPNs, proxies, or Tor, the visible IP belongs to the exit

      VPN, Proxy & Tor Detection

      Bi-weekly Security module ~65% 100 req/month ipstack Daily Privacy Detection API ~72% 50k req/month IPinfo Monthly (LITE) PX series add-on ~70% LITE (free) IP2Location Twice weekly Via separate DB ~67% GeoLite2 (free) MaxMind GeoIP2 Update Freq. VPN Detection City Accuracy Free Tier Provider

      Provider Comparison

      approximation, not a GPS replacement.

      ⚠️ Never use IP geolocation for street-level decisions like emergency dispatch. It is a coarse

      Typically city-center or ISP hub; never street-level ~25 km radius Coordinates Often a best-guess centroid; not suitable for precise targeting 20–50% Postal Code Varies widely by country; dense urban areas are better 55–80% City Good for most broadband ISPs; mobile carriers less reliable 80–90% Region / State RIR data is highly reliable; errors near borders 95–99% Country Notes Typical Accuracy Level

      Accuracy by Resolution Level

      points. When an IP is seen on a known Wi-Fi network, it inherits that network's location. Mobile apps that collect Wi-Fi BSSID scans alongside GPS fixes create dense maps of access

      Wi-Fi & GPS Crowdsourcing

      using multilateration. known landmarks (routers with confirmed locations) let algorithms estimate city-level positions Providers run latency-based measurements from globally distributed probes. Round-trip times to

      Active Probing & Traceroute

      providers refine regional accuracy. for specific IP prefixes. By mapping ASNs to known organizations and their physical locations, Border Gateway Protocol announcements reveal which Autonomous Systems (ASNs) originate routes

      BGP Routing Data

      These are the most authoritative source for country-level accuracy. AFRINIC (Africa) — publish delegation files that map IP blocks to countries. APNIC (Asia-Pacific), LACNIC (Latin America), and The five RIRs — ARIN (North America), RIPE NCC (Europe/Middle East),

      Regional Internet Registries (RIRs)

      Data Sources: RIRs, BGP, Traceroute & Wi-Fi

      ISP, and organization name.

      ranges (CIDR blocks) to geographic metadata such as country code, region, city, latitude/longitude,

      📖 Definition — An IP geolocation database is a structured mapping of IP address

      to triangulate locations. observational sources. No single technique delivers full accuracy, so providers layer methods IP geolocation providers compile databases by aggregating data from multiple authoritative and

      How Geolocation Databases Are Built

    • References
    • Tools
    • Common Mistakes
    • Best Practices
    • Privacy & GDPR Considerations
    • API Example: JavaScript Fetch
    • VPN, Proxy & Tor Detection
    • Provider Comparison
    • Accuracy by Resolution Level
    • Data Sources: RIRs, BGP, Traceroute & Wi-Fi
    • How Geolocation Databases Are Built
      1. 📑 Table of Contents

        and see working API code examples. under GDPR and similar regulations. You'll also learn how VPNs, proxies, and Tor affect accuracy, major providers, examines accuracy at each resolution level, and covers privacy implications postal code or coordinates. This guide explains how geolocation databases are built, compares IP geolocation maps an IP address to a physical location — country, region, city, and sometimes

        IP geolocation maps an IP address to a physical location — country, region, city, and sometimes postal code. This article explains how geolocation databases are built, compares major providers, examines accuracy at each level, and covers the privacy and technical limitations every developer should know.

        How Geolocation Databases Are Built

        No single data source can reliably map every IP address to a location. Commercial geolocation providers combine multiple signals and cross-reference them to improve confidence.

        📖 Definition — IP geolocation is the process of estimating the geographic position of a device using its Internet Protocol address. It relies on mapping IP blocks to locations through registry data, network measurements, and supplementary signals.

        Regional Internet Registry (RIR) Data

        The five RIRs — ARIN (North America), RIPE NCC (Europe/Middle East/Central Asia), APNIC (Asia-Pacific), LACNIC (Latin America), and AFRINIC (Africa) — allocate IP blocks to ISPs and organisations. Each allocation record includes the registrant's country. This is the foundation layer and provides reliable country-level accuracy.

        BGP Routing Analysis

        Border Gateway Protocol announcements reveal which Autonomous Systems (AS) originate specific prefixes. By correlating AS numbers with known ISP service areas, providers refine location down to the regional level.

        Active Network Measurements

        Traceroute and latency probes from known vantage points triangulate an IP's position. Round-trip times to geographically anchored landmarks (e.g., data centres with confirmed addresses) help estimate city-level placement.

        Supplementary Signals

        • Wi-Fi BSSID mapping — crowd-sourced access-point locations (used by mobile devices)
        • User-submitted corrections — feedback loops from end-users and ISPs
        • GPS-tagged web traffic — opt-in telemetry from apps and browsers
        • Reverse DNS hostnames — ISP naming conventions that embed city codes (e.g., lax, cdg)

        Accuracy by Level

      LevelTypical AccuracyReliable?Notes
      Country95–99%HighRIR data alone is usually sufficient
      Region / State75–90%MediumDepends on ISP allocation granularity
      City50–80%MediumMobile IPs and CGNAT reduce accuracy
      Postal Code20–50%LowOften a best-guess centroid
      Street / Exact<5%Very LowNot feasible from IP alone

      ⚠️ Mobile carrier IPs are frequently registered to a central hub city, not the subscriber's actual location. A user in a rural town may geolocate to the nearest metro area.


      Provider Comparison

      ProviderFree TierUpdate FrequencyStrengths
      MaxMind GeoLite2Yes (account required)Bi-weeklyIndustry standard, wide language support
      IP2Location LITEYesMonthlyCompact binary DB, fast lookups
      IPinfo50k req/monthDailyClean API, ASN & privacy detection included
      DB-IPYes (lite)MonthlyGood city-level accuracy in Europe
      ipstack100 req/monthReal-timeSimple REST API, currency/timezone extras

      VPN, Proxy & Tor Detection

      Geolocation becomes unreliable when users route traffic through anonymisation layers. Modern providers flag these with dedicated detection datasets.

      1. VPN Detection
      Providers maintain lists of IP ranges belonging to known VPN services. Detection rates vary from 70–95%.

      2. Open Proxy Detection
      Port scanning and honeypot traffic identify open proxies. These IPs are flagged and updated frequently.

      3. Tor Exit Nodes
      The Tor project publishes its exit relay list. Matching is straightforward but exit IPs rotate often.

      4. Residential Proxies
      The hardest to detect — real ISP IPs rented through SDK-based networks. Heuristics and traffic pattern analysis are required.


      API Example: IP Lookup in JavaScript

      // Fetch geolocation data from IPinfo (free tier)
      async function lookupIP(ip) {
        const token = 'YOUR_TOKEN'; // replace with your IPinfo token
        const res = await fetch(`https://ipinfo.io/${ip}?token=${token}`);
        if (!res.ok) throw new Error(`Lookup failed: ${res.status}`);
        const data = await res.json();
        return {
          ip: data.ip,
          city: data.city,
          region: data.region,
          country: data.country,
          org: data.org,
          loc: data.loc, // "lat,lng"
        };
      }
      
      // Usage
      lookupIP('8.8.8.8').then(console.log);

      🚀 Pro Tip — Cache geolocation results for at least 24 hours. IP-to-location mappings rarely change more than once a week, and caching reduces API costs dramatically.


      Privacy & GDPR Considerations

      🔴 Under GDPR, an IP address is classified as personal data. Storing or processing IP geolocation data for EU residents requires a lawful basis (e.g., legitimate interest) and must be disclosed in your privacy policy.

      • Minimise data — store country/region only if city-level precision isn't needed
      • Anonymise IPs after geolocation (truncate the last octet)
      • Honour Do Not Track signals when using geolocation for analytics
      • Provide opt-out mechanisms for location-based personalisation
      • Document your data processing in Records of Processing Activities (ROPA)

      Best Practices

      Use multiple providers
      Cross-reference two databases for critical decisions like fraud detection or content licensing.

      Keep databases updated
      IP allocations change constantly. Stale data degrades accuracy within weeks.

      Never trust city-level for access control
      Use country-level for geo-restrictions; city-level is informational only.

      Implement graceful fallbacks
      If geolocation fails or returns low confidence, default to a sensible experience rather than blocking the user.


      Common Mistakes

      • ❌ Assuming city-level geolocation is precise enough for delivery addresses
      • ❌ Using geolocation as sole evidence for fraud — false positives are common with mobile and corporate IPs
      • ❌ Ignoring CGNAT — millions of users may share one public IP, all geolocating to the ISP's hub
      • ❌ Hardcoding geolocation provider responses — APIs change format without warning
      • ❌ Not handling IPv6 — many databases have poorer IPv6 coverage

      Tools

      🌍 IP Address Lookup
      Geolocate any IPv4 or IPv6 address instantly — country, city, ISP, and coordinates.

      📍 Geo Checker
      Verify how your website appears from different geographic locations.


      References


      🎯 Key Takeaway — IP geolocation is powerful for country-level decisions and user personalisation, but its accuracy drops sharply below regional level. Always treat it as an estimate, combine it with other signals for high-stakes decisions, and respect user privacy by minimising data collection and complying with GDPR.

      Continue Reading

      Related Articles

      Free & Private

      Explore Our Free Tools

      40+ browser-based utilities — fast, private, and always free. No sign-up required.

      Browse All Tools