Background
To enhance security on a WordPress site I maintain, I recently configured global rate limiting rules in Nginx. Shortly after applying the configuration, I found that I could not properly add or save tags while editing posts. 429 Too Many Requests and 400 Bad Request appeared frequently in the browser console and Nginx logs. After a step-by-step investigation, I identified the overly strict rate limiting rules as the culprit. This article documents the symptoms, troubleshooting process, solution, and verification steps in full, hoping to provide a reference for anyone encountering similar issues. Reference: 从单日126次504超时到彻底稳定:WordPress 1核2G服务器极限优化全记录(附全部实操命令)
1. Symptoms
When editing a post in the WordPress backend, attempting to add a new tag or save existing tags resulted in the following:
- The tag input box responded slowly, sometimes with no response after typing characters.
- A prompt appeared at the bottom of the page stating, “This response is not a valid JSON response.”
- Refreshing the page revealed that some tags had not been saved.
- The browser developer tools (Network tab) showed numerous requests to
/wp-json/wp/v2/tagsreturning status codes429or400.

2. Nginx Rate Limiting Configuration (Problematic Configuration)
Inside the http block of the main configuration file nginx.conf:
# Global rate limit: 6 requests per second per IP, memory cache for 100,000 IPs
limit_req_zone $binary_remote_addr zone=site_limit:10m rate=6r/s;
# Maximum concurrent connections per IP: 20
limit_conn_zone $binary_remote_addr zone=conn_limit:10m;At the beginning of the server block in the site virtual host configuration vhost/www.example.com.conf:
# Enable request rate limiting, burst buffer of 12, no delay
limit_req zone=site_limit burst=12 nodelay;
# Concurrent connection limit: 20
limit_conn conn_limit 20;
# Return 429 when limit is exceeded
limit_req_status 429;3. Troubleshooting Process
1. Confirming if Rate Limiting Was Triggered
First, I checked the Nginx access logs to count the number of 429 status codes:
grep -c " 429 " /data/wwwlogs/www.example.com_nginx.log
# 输出:738This indicated that the rate limiting rules were triggering extensively. But was the issue directly related to the tag API? I further filtered the 429 responses for the tag interface:
grep "/wp-json/wp/v2/tags" /data/wwwlogs/www.example.com_nginx.log | grep -c " 429 "
# 输出:28Definitive proof: the tag REST API requests were being intercepted by rate limiting.
2. Monitoring Request Status in Real Time
I used tail -f to observe the live logs while operating the tags:
tail -f /data/wwwlogs/www.example.com_nginx.log | grep "/wp-json/wp/v2/tags"Example output:
211.137.80.234 - - [05/Jun/2026:20:48:20 +0800] "POST /wp-json/wp/v2/tags?_locale=user HTTP/2.0" 429 177 "..."Numerous 429 appeared, with multiple requests rejected per second.
3. Analyzing Why Tag Operations Trigger Numerous Requests
The WordPress block editor (Gutenberg) frequently calls the REST API when handling tags:
- Searching tags: Every time a user types a character in the tag input box, a
GET /wp-json/wp/v2/tags?search=xxxis sent. - Creating new tags: When a non-existent tag name is entered and loses focus, a
POST /wp-json/wp/v2/tagsis sent to create it. - Saving the post: Tag IDs are batch-associated upon submission.
When editing an article that already has 20 tags, the aforementioned requests might be sent 20 to 30 times within a few seconds. However, our rate limiting rule was set to 6 requests/second, allowing a maximum burst of 12 queued requests at any instant. Once exceeded, it directly returned 429.
Upon receiving 429 on the frontend, certain scripts would enter a retry loop (especially when the response body was not as expected), causing continuous retries of the same POST request from the same IP in the logs, further exacerbating the situation.
4. Why Were 400 Errors Also Present?
In the logs, we found that some requests returned 400. This is because:
- When users quickly create new tags, the frontend might send multiple identical
POSTrequests consecutively (for example, due to an imperfect debounce mechanism or network retries). - The WordPress REST API returns
400when it receives duplicate tag names (indicating “this tag already exists” or “parameter error”). - This situation does not affect the final tag creation—the first request successfully creates the tag, and subsequent duplicate requests return
400, but the post can still be saved by associating the already created tag ID.
Therefore, the 400 errors are redundant responses caused by duplicate frontend requests, not the root cause of the save failure. The truly fatal issue is 429, because the requests are intercepted directly by Nginx and never even reach the WordPress application layer.
4. Solution
The essence of the problem was that the rate limiting threshold was too low to accommodate the request frequency required for normal editing operations. There are two solutions: increase the rate limiting parameters or exempt the REST API path from rate limiting. Considering configuration simplicity and the desire to retain some security protection, we chose to increase the parameters.
Modification Steps
- Edit the main configuration file to increase the rate:
vi /usr/local/nginx/conf/nginx.confChange:
limit_req_zone $binary_remote_addr zone=site_limit:10m rate=6r/s;To:
limit_req_zone $binary_remote_addr zone=site_limit:10m rate=30r/s;- Edit the site configuration file to increase the burst buffer:
vi /usr/local/nginx/conf/vhost/www.example.com.confChange:
limit_req zone=site_limit burst=12 nodelay;To:
limit_req zone=site_limit burst=50 nodelay;Optionally, increase the concurrent connection limit as well:
limit_conn conn_limit 50;- Restart Nginx:
service nginx restartTuning Notes
rate=30r/s: Allows an average of 30 requests per second, enough to cover the normal peak of tag operations (about 15 to 20 requests/second during fast typing) while still preventing brute-force attacks.burst=50: Allows up to 50 requests to queue instantaneously, avoiding rate limit triggers caused by concurrent resource requests during page loads.- If server performance is robust, these can be further increased to
50r/s,burst=80.
5. Verification and Results
After applying the modifications, I went back to the WordPress backend to edit posts, add tags, and save. Observing the logs:
tail -f /data/wwwlogs/www.example.com_nginx.log | grep "/wp-json/wp/v2/tags"429 no longer appeared; there were only a few successful 200 responses and occasional 400 (caused by duplicate frontend requests, which did not affect the final save). The post tags saved successfully, and the issue was resolved.

6. Lessons Learned and Recommendations
- Rate limiting is a double-edged sword: Proper configuration can defend against CC attacks and brute-force cracking, but thresholds set too low will disrupt normal user operations, especially in modern editors that rely on frequent API calls.
- Monitor and test: Before applying rate limiting rules, it is recommended to run in a lenient mode and observe access logs, adjusting
rateandburstbased on actual business request frequencies. - Granular rate limiting: If you wish to retain strict rate limiting, you can apply different strategies to different paths. For example:
- Maintain
rate=6r/sfor/wp-login.php,/xmlrpc.php. - Set a higher threshold or completely exempt
/wp-json/*. Example configuration snippet:
location /wp-json/ {
limit_req zone=api_limit burst=100 nodelay;
# Other configurations
}- Distinguish between 429 and 400:
429is returned by the rate limiting middleware, meaning the request never reached the application layer;400is returned by the application layer and is typically related to the request content (such as duplicate submissions or parameter validation failures). When troubleshooting, first confirm whether429exists, as it causes more severe functional disruption. - Document changes: After every Nginx configuration modification, it is recommended to record the changes and date for future traceability.
7. Conclusion
A seemingly complex tag save failure issue was ultimately rooted in overly conservative Nginx rate limiting parameters. By analyzing access logs, identifying 429 responses, and adjusting the rate limiting thresholds, the problem was resolved with minimal cost. I hope the troubleshooting approach and solution in this article prove helpful for your WordPress operations. If you are experiencing similar 429 issues, consider checking your Nginx rate limiting configuration first—it might save you a lot of effort.
Appendix: Common Troubleshooting Commands Cheat Sheet
- Count 429s:
grep -c " 429 " /path/to/access.log- Monitor tag API in real time:
tail -f access.log | grep "/wp-json/wp/v2/tags"- Test configuration syntax:
nginx -t

