1. Status Codes
Official

HTTP Error 429: Too Many Requests

Posted by

When interacting with websites and APIs, the servers return status codes to inform if the request has been processed successfully or not.

One of those codes is the 429 or Too Many Requests error, and in this article we’ll explain what it is, when it shows up, and possible ways to avoid it.

Also, if you are working with an API, we’ll give you a handy resource to test the 429 HTTP status code from your scripts.

What is the HTTP Error 429?

This error belongs to the family of 4xx HTTP status codes, indicating that the problem’s source is on the client side.

More precisely, the 429 error is returned when the server determines that there have been too many requests in a given amount of time. This concept is also known as rate limiting.

What causes the HTTP Error 429?

If you are receiving the 429 error as a response to an API request, you may have sent an excessive amount of calls in a short time.

It can also be that your IP or the token you are using to connect to the API has a limited number of requests per minute, hour, or day.

These restrictions imposed by the servers could be for a variety of reasons:

  • As a security measure to prevent a user or a bot from carrying out a denial-of-service (DoS) attack or brute force attack. In other words, it’s a preventive measure to ensure that clients do not abuse server resources.
  • As a usage limitation in a paid API, when the request limit has been reached for the contracted plan within a period of time.
  • As a usage limitation in a free API, to prevent users from overloading the server.

How can I fix the HTTP Error 429?

The only way to resolve error 429 is to wait. The server will keep returning the 429 status code until the time period set for rate limiting has elapsed.

In some cases, the API will return the Retry-After header indicating the time you should wait, in seconds, before making another request. For example:

HTTP/1.1 429 Too Many Requests
Content-Type: application/json; charset=utf-8
Retry-After: 3600

Finally, if you’re able to, contact the owner of the API and ask to increase the request limit or upgrade the plan to allow for more calls.

How can I avoid the HTTP Error 429?

The most important thing to avoid the 429 error is knowing the API’s request limits and their application period.

Based on this information, develop your app to avoid surpassing them, for example, by implementing a backoff or an exponential backoff. In other words, retry requests at increasingly longer intervals to prevent server saturation.

How can I test the HTTP Error 429?

If you’re working with an API and need to reproduce a specific HTTP status code during your testing, you can do so through httpstatus.is. It’s a very simple service designed to help you check how your code handles different HTTP responses.

To test the 429: Too Many Requests code, call the httpstatus.is/429 endpoint.

The server will return a JSON response similar to this:

HTTP/1.1 429 Too Many Requests
Content-Length: 62
Content-Type: application/json; charset=utf-8
x-powered-by: www.helloapi.co

{
    "code": 429,
    "description": "Too Many Requests",
    "official": true
}

See also

Discover how Hello API can improve your API visibility and adoption