Troubleshooting guide
Apache "server reached MaxRequestWorkers": how to fix it
Every Apache worker is occupied and new connections must wait. Often the design, using prefork with mod_php, is the real limit.
3 min read10 sectionsUpdated
On this page
Diagnose it
The scoreboard shows what workers are doing, and process size shows how many you can afford.
# Active MPM and limits
apachectl -V | grep -i mpm
apachectl -t -D DUMP_RUN_CFG | head
# Enable mod_status, then read the scoreboard
curl -s 'http://127.0.0.1/server-status?auto' | grep -E 'BusyWorkers|IdleWorkers|Scoreboard'
# Average process size (MB)
ps -ylC apache2 --sort=rss | awk 'NR>1 {s+=$8; n++} END {print s/n/1024 " MB"}'Fixes
Switch to mpm_event with PHP-FPM, so workers are not held by idle connections or by PHP's memory footprint. Set MaxRequestWorkers using the formula (RAM available) / (process size), as exceeding memory causes swapping. Reduce KeepAliveTimeout to a few seconds under prefork. Find slow requests in the scoreboard or the logs, and add caching. After changing MPM, restart Apache fully rather than reloading, and confirm the change with apachectl -V. Check afterwards that your modules are thread-safe under the event MPM.
Reading the scoreboard
Each character is one worker: W writing a reply, R reading a request, K in keep-alive, _ idle, and . an open slot. Many Ws suggest a slow application. Many Rs suggest slow clients or an attack, and mod_reqtimeout will help. Many Ks under prefork mean idle browsers are holding your most expensive resource, and the event MPM eliminates that. Check too that your ServerLimit allows the value, as MaxRequestWorkers cannot exceed the product of ServerLimit and ThreadsPerChild.
Catch it automatically
Export BusyWorkers and alert before saturation. Apache monitoring tracks workers and request rate. Add an uptime check to verify what visitors see.
Related reading
- Cloudflare error 521: web server is down: Fix Cloudflare error 521 "Web server is down": the origin refused the connection. Check the web server, firewall rules for Cloudflare IPs and DNS.
- "DNS server not responding": how to fix it: Fix "DNS server not responding" on Windows and Mac: restart the router, flush DNS, switch to 1.1.1.1 or 8.8.8.8, and check adapters, VPNs and firewalls.
- Cloudflare error 520: web server returns an unknown error: Fix Cloudflare error 520 "Web server returns an unknown error": empty or reset origin responses, crashes, oversized headers and keep-alive mismatches.
- ERR_PROXY_CONNECTION_FAILED: how to fix it: Fix ERR_PROXY_CONNECTION_FAILED ("No internet, there is something wrong with the proxy server"): remove stale proxies, fix PAC files and VPN leftovers.
- "This site can’t be reached": how to fix it: Fix Chrome’s "This site can’t be reached": DNS failures, refused or timed-out connections and blocked networks, for visitors and for site owners.
- 500 Internal Server Error: how to find the cause: A 500 error means your code failed. Find the exception behind it fast with logs, traces and error tracking, and learn how to prevent repeats.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.