Software⏱️ 4 min read📅 2026-06-11

How to Fix error 503 Error – What's the reasoning for nginx defaulting to error 503 when a rate limit applies instead of error 429?

Nginx defaulting to error 503 when rate limit applies instead of error 429, why?

Quick Answer: The issue is due to the default configuration of nginx. To fix it, you can override the limit-req-status-code annotation with HTTP/1.1 status code 429.

When rate limiting is applied in Nginx, it can lead to unexpected HTTP error codes being returned. In particular, when a rate limit applies, users may expect to see an HTTP 429 Too Many Requests response code. However, instead of this, they might receive an HTTP 503 Service Unavailable response code. This issue affects users who are experiencing high traffic or concurrent requests on their Nginx-based applications.

This behavior can be frustrating for developers and users alike, as the HTTP 503 status code does not accurately convey the reason for the error. In this guide, we will explore the root causes of this issue and provide steps to resolve it.

🛑 Root Causes of the Error

  • The primary reason why Nginx returns an HTTP 503 response code when a rate limit applies is due to the way the `limit-connections` and `limit-rps` annotations are configured. These annotations control the number of concurrent connections allowed from a single IP address and the number of requests accepted per second, respectively. When these limits are exceeded, Nginx returns an HTTP 503 response code instead of the expected HTTP 429 response code.
  • An alternative reason for this behavior is that the `limit-req-status-code` annotation is not being used correctly. This annotation allows developers to override the default status code returned when rate limiting occurs. If this annotation is not set or is set incorrectly, Nginx may return an HTTP 503 response code instead of the expected HTTP 429 response code.

🔧 Proven Troubleshooting Steps

Configuring `limit-req-status-code` to Return HTTP 429

  1. Step 1: To resolve this issue, you need to set the `limit-req-status-code` annotation in your Nginx configuration file. This annotation specifies the HTTP status code to return when rate limiting occurs. For example, you can add the following line to your configuration file: `limit-req-status-code 429;`. This will tell Nginx to return an HTTP 429 response code instead of the default HTTP 503 response code.
  2. Step 2: Once you have added this annotation to your configuration file, restart the Nginx service for the changes to take effect. You can verify that the `limit-req-status-code` annotation is working correctly by checking the Nginx logs or using a tool like curl to test the rate limiting behavior.

Configuring `nginx.ingress.kubernetes.io/limit-rps` with Burst Multiplier

  1. Step 1: Another way to resolve this issue is to configure the `nginx.ingress.kubernetes.io/limit-rps` annotation with a burst multiplier greater than 1. This will allow Nginx to accept more requests per second, reducing the likelihood of exceeding the rate limit and returning an HTTP 503 response code.
  2. Step 2: To configure the burst multiplier, add the following line to your configuration file: `nginx.ingress.kubernetes.io/limit-rps: ;`. For example, you can set the burst multiplier to 10 by adding the following line: `nginx.ingress.kubernetes.io/limit-rps: 10;`. This will increase the number of requests accepted per second and reduce the likelihood of returning an HTTP 503 response code.

💡 Conclusion

In conclusion, the reason why Nginx returns an HTTP 503 response code when a rate limit applies is due to incorrect configuration of the `limit-connections` and `limit-rps` annotations. By configuring these annotations correctly or using alternative methods such as setting the `limit-req-status-code` annotation or increasing the burst multiplier, developers can resolve this issue and return an accurate HTTP 429 response code when rate limiting occurs.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions