Blog·Craft·

127.0.0.1 is not an error

Loopback, private, and other special-use IPs return 200 with empty geo. The address is valid. There is just nowhere to put it on a map.

Your laptop is not a country.

GET /ip/127.0.0.1
{
  "ip": "127.0.0.1",
  "country": null,
  "country_name": null,
  "continent": null,
  "asn": null,
  "asn_name": null
}

Loopback, private ranges, link-local, and the rest of special-use space are valid addresses. They have no registry country and no ASN. /ip/127.0.0.1 and /ip/::1 return 200 with the address and empty geo. 10.0.0.1 and 192.168.1.1 do the same. Invalid shape is still 400. A public IP with no data is still 404. Your error handler should not fire because a local lookup worked.

Empty geo is the answer

country null on loopback is not a hole. There is no country. Paid ?deep=true ships the bag with nulls and false flags, same as any other IP that has nothing to add. The JSON stays the same shape, so a client that already reads country can keep reading it.

Try it

Call /ip with 127.0.0.1 from your own machine. 200. Nothing on the map. That is the whole point.