429 Too Many Requests
Fault: Client
TL;DR
Rate limit exceeded.
The user has sent too many requests in a given amount of time.
What This Error Means
The user has sent too many requests in a given amount of time.
Rate limit exceeded.
Common Causes
- API rate limit exceeded
- Too many login attempts
- DDoS protection triggered
- Scraping detected
How to Fix It (For Visitors)
- Wait before retrying
- Slow down request rate
- Try again later
How to Fix It (For Developers/Admins)
- Implement exponential backoff
- Check Retry-After header
- Reduce request frequency
- Cache responses
- Use request queuing
Code Examples
Here's how to return a 429 status code in various programming languages:
Python (Flask)
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/endpoint')
def endpoint():
return jsonify({"message": "Too Many Requests"}), 429
Node.js (Express)
const express = require('express');
const app = express();
app.get('/endpoint', (req, res) => {
res.status(429).json({ message: 'Too Many Requests' });
});
PHP
<?php
http_response_code(429);
header('Content-Type: application/json');
echo json_encode(['message' => 'Too Many Requests']);
?>
Go
package main
import (
"encoding/json"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(429)
json.NewEncoder(w).Encode(map[string]string{
"message": "Too Many Requests",
})
}
Java (Spring Boot)
@GetMapping("/endpoint")
public ResponseEntity<Map<String, String>> endpoint() {
Map<String, String> response = new HashMap<>();
response.put("message", "Too Many Requests");
return ResponseEntity.status(429).body(response);
}
Ruby (Sinatra)
get '/endpoint' do
status 429
json message: 'Too Many Requests'
end
Browser Compatibility
| Browser | Support | Notes |
|---|---|---|
| Chrome | ✓ Full Support | All versions |
| Firefox | ✓ Full Support | All versions |
| Safari | ✓ Full Support | All versions |
| Edge | ✓ Full Support | All versions |
Official Specification
This status code is defined in RFC 6585.