IP geolocation
import { TabItem, Tabs } from "~/components";
IP geolocation adds the CF-IPCountry header to all requests to your origin server.
Availability
| Free | Pro | Business | Enterprise | |
|---|---|---|---|---|
| Availability | Yes | Yes | Yes | Yes |
Add IP geolocation information
The recommended procedure to enable IP geolocation information is to enable the Add visitor location headers Managed Transform. This Managed Transform adds HTTP request headers with location information for the visitor's IP address, such as city, country, continent, longitude, and latitude.
If you only want the request header for the visitor's country, you can enable IP Geolocation.
To enable IP Geolocation in the dashboard:
- Log in to your Cloudflare account and go to a specific domain.
- Go to Network.
- For IP Geolocation, switch the toggle to On.
To enable IP Geolocation with the API, send a PATCH request with ip_geolocation as the setting name in the URI path, and the value parameter set to "on".
:::note
In order to use this data, you will need to then retrieve it from the CF-IPCountry header.
:::
Accuracy and limitations
IP geolocation is an estimate, not an exact science. There is nothing that inherently binds an IP address to a physical location or country. Because IP addresses rotate and ownership can change, the data is dynamic and may shift over time.
:::caution
For use cases where location must be highly precise or compliance-critical, such as state-based access restrictions, do not use IP geolocation as the sole signal. Combine it with device GPS or other first-party signals, with appropriate user consent and compliance with applicable privacy laws.
:::
Here is what you can expect regarding data accuracy and updates:
- Update frequency: Cloudflare automatically updates its IP geolocation database multiple times per week.
- Processing time: Cloudflare reviews correction requests, which may or may not result in a change. Confirmed changes generally take effect within a few business days.
- Accuracy: Due to the dynamic nature of IP address allocation, Cloudflare cannot guarantee that its IP geolocation will align with other providers. Cloudflare does not provide SLAs for IP geolocation accuracy or the timing of updates.
Report an incorrect IP location
If you find an IP address with a location that you believe is incorrect, fill in the data correction form with the relevant IP address range(s) along with the correct information as applicable (country, state/province, city name, and ZIP code).
If the data is confirmed, Cloudflare will make the necessary changes, generally within a few business days.
If Cloudflare cannot confirm the submitted location, the correction does not result in a change.
If an end user's IP address rotates frequently, for example on mobile or CGNAT networks, the address may change again before the correction completes.
谢谢你的反馈!