As a website owner, you’ll run into an error message from time to time. Some of these errors will be relatively simple to solve, while others will be more intricate. Take the HTTP Error 429 for example.
Troubleshooting this error is complicated because it provides few details on what it is or how to solve it. You know something’s wrong and you need to fix it — but you’re not exactly sure what happened or why.
To make sure you understand and can fix this problem, we’ll go over what the 429 error means and what its most common solutions are.
HTTP Error 429
HTTP Error 429 is an HTTP response status code that indicates the client application has surpassed its rate limit, or number of requests they can send in a given period of time. Typically, this code will not just tell the client to stop sending requests — it will also specify when they can send another request.
What causes an Error 429?
A 429 response is not technically an error — it’s a response from a server, application programming interface (API), or plugin that tells the client application to stop sending requests because they simply don’t have enough resources to accept it at this time. The client application usually refers to a website or app, but can also refer to individual users like the site admin or a site visitor or hacker.
For example, if a user is trying to access a page on your website too often in a short period of time, your server may send a 429 error. In the case of a brute-force login attempt, in which a hacker repeatedly tries to log into your site, the rate limit is an important security measure. But the rate limit will also kick in if your website is using up too many resources on a shared hosting server or service. If, for example, more than 50 requests are received from an IP address within one minute, PayPal Sandbox will block that IP for the next five minutes.
While the 429 response may seem punitive, it’s actually a protective measure against users intentionally or accidentally abusing server resources (or an API, plugin, or another service). It’s designed to prevent a backup or overflow of requests that would strain a server, or other service, that is meant to be shared and consumed by many websites and apps. So, by controlling the number and timing of requests, rate limits prevent problems before they arise.
If you are seeing the HTTP 429 error on your site for other reasons, you may need to reduce the number of server requests or API calls you’re making. The steps discussed below are general fixes for the 429 “Too Many Requests Error.” If you have a WordPress site, then you may need a WordPress-specific solution.
How to Fix an HTTP 429 Error
- Wait to send another request.
- Implement exponential backoff.
- Set your own throttling limit.
- Contact your hosting provider.
Most of the steps below focus on avoiding, rather than retroactively fixing, an HTTP 429 error. Take a look.
1. Wait to send another request.
The simplest way to fix an HTTP 429 error is to wait to send another request. Often, this status code is sent with a “Retry-after” header that specifies a period of time to wait before sending another request. It may specify only a few seconds or minutes.
Here’s an example that asks the client to wait an hour before sending another request.
HTTP/1.1 429 Too Many Requests
<title>Too Many Requests</title>
<h1>Too Many Requests</h1>
<p>Only 100 requests per hour per logged in user is allowed on this website. Try again soon.</p>
2. Implement exponential backoff.
If a “Retry-after” header is not sent and you don’t know how long to wait before trying, you should implement retries with exponential backoff. Using this approach, your application will not immediately repeat a failed request; instead, it will perform a series of retries with progressively longer wait times between each attempt. When the request is finally accepted, then you will know what wait time or rate is acceptable.
You can add code to implement this approach, or you can use a tool like Celery that comes with a built-in exponential backoff feature.
3. Set your own throttling limit.
Throttling is the process of limiting the number of requests an application can submit in a given amount of time. If this limit is exceeded, the server or API requests will typically be dropped or fulfilled with cached data.
While this approach is most often used by third-party APIs or platforms to prevent client apps from exceeding their limits, it can also be useful for restricting your own consumption of third-party APIs or server resources. In fact, you can implement a stricter throttling limit for yourself to prevent going over the limits of a server, API, or other service you’re using. This is an especially good idea if you’re using a costly API, like the Twitter API, and don’t want to exceed your usage policy.
4. Contact your hosting provider.
Contacting your hosting provider is always an option for any error on your website, but it should be one of the last options you try.
If you’ve tried the steps above and are still seeing the 429 error, it’s possible that the cause originated from your server and not your website. It’s also possible that your host blocks requests from specific third-party services or platforms, like Google Search Console, which makes lots of requests to websites. By reaching out to your provider, they may be able to solve the issue or provide valuable insight.
How to Avoid an HTTP 429 Error
The most simple way to avoid this error is to reduce the number of requests made in a short period of time. The server is keeping track of how many requests per time unit you make and will enforce it — leading to a temporary block if exceeded. Some servers send this information in the header, on rare occasions.
And remember, receiving a 429 is not necessarily an error, it’s the server’s way of telling you your rate of requests is too high and not willing to accept those actions.
Though in some instances, the reason for the error may be your server rather than with your website. If that’s the case, nothing you will do from your side will help and you should contact your hosting provider for resolution.
Resolving the HTTP 429 Error
An HTTP 429 Error is common, but can be avoided by paying attention to rate limits set by your server, API, plugin, or more. If you exceed those limits, there are steps you can take to resolve a 429 error. By doing so, you’ll continue to provide visitors with seamless user experiences on your site.
This article was originally published in December 2020 and has been updated for comprehensiveness.