Skip to main content

Error codes

OpenWeatherMap Weather API 2.5 and Geocoding API 1.0 report request outcomes through HTTP status codes paired with a JSON response body.

For retry policies, timeout guards, and safe JSON parsing patterns, see Handle errors in production and Common errors.

HTTP status codes​

Status codeMeaningDescription
200OKRequest succeeded. Returns a JSON object or JSON array depending on the endpoint.
400Bad RequestRequest is missing a required parameter or contains an invalid parameter value, such as omitted coordinates ("Nothing to geocode") or out-of-range latitude and longitude ("wrong latitude" or "wrong longitude").
401UnauthorizedAuthentication failed due to a missing appid, an invalid or revoked key, a newly generated key awaiting activation, or an endpoint outside your subscription plan. See Authentication.
404Not FoundRequested city name, city ID, postal code, or endpoint path does not exist. Whereas /geo/1.0/zip returns 404 for unknown postal codes, /geo/1.0/direct and /geo/1.0/reverse return 200 OK with an empty array ([]).
429Too Many RequestsRequest exceeded the account rate limit (60 calls per minute on the free tier) or monthly quota. See Rate limits.
500Internal Server ErrorUnhandled server error on OpenWeatherMap application nodes.
502 / 503 / 504Bad Gateway / Service Unavailable / Gateway TimeoutTransient upstream load balancer or reverse proxy failure. Responses can return an HTML document (text/html) rather than a JSON payload.

Error payload schema​

Application-layer 4xx and 500 errors return a JSON object with the following fields:

FieldTypeDescription
codnumber | stringInternal status code mirroring the HTTP status code. Serialized as either a number or a string depending on the status code and endpoint.
messagestringHuman-readable diagnostic description of the error condition.

cod data type matrix​

OpenWeatherMap serializes the cod property inconsistently across endpoints and status codes. Inspect the HTTP transport status code (response.status in Node.js or response.status_code in Python) instead of comparing cod with strict type equality.

HTTP status/data/2.5/weather/data/2.5/forecast/geo/1.0/direct and /geo/1.0/reverse/geo/1.0/zip
200 OKnumber (200)string ("200")Absent (root is JSON array [])Absent (root is location object)
400 Bad Requeststring ("400")string ("400")string ("400")string ("400")
401 Unauthorizednumber (401)number (401)number (401)number (401)
404 Not Foundstring ("404")string ("404")Not returned for unmatched queries (200 with [])string ("404")
429 Too Many Requestsnumber (429)number (429)number (429)number (429)
500 Internal Server Errornumber or stringnumber or stringnumber or stringnumber or string
502 / 503 / 504Absent if HTML gateway bodyAbsent if HTML gateway bodyAbsent if HTML gateway bodyAbsent if HTML gateway body

Error response examples​

400 Bad Request​

Returned when required location parameters are missing or empty, or when lat or lon falls outside valid geographic bounds:

{
"cod": "400",
"message": "Nothing to geocode"
}

401 Unauthorized​

Returned when appid is missing, invalid, pending activation, or unauthorized for the target endpoint:

{
"cod": 401,
"message": "Invalid API key. See https://openweathermap.org/faq#error401 for more info."
}

404 Not Found​

Returned when a city query on /data/2.5/weather or /data/2.5/forecast or a postal code on /geo/1.0/zip matches no record:

{
"cod": "404",
"message": "city not found"
}

429 Too Many Requests​

Returned when account request volume exceeds your subscription rate limit:

{
"cod": 429,
"message": "Your account is temporary blocked due to exceeding of requests limitation of your subscription type."
}