Fix "Failed to read FastCGI header" Apache error
The Apache web server will log the message “Failed to read FastCGI header” in an app’s Apache error log when the PHP-FPM process Apache was communicating with terminates unexpectedly.
The most common cause of this problem is a server running out of memory due to slow PHP code. When a server runs out of memory, the operating system kernel has to kill running processes. When a PHP-FPM child process is killed, the request that process was handling will fail and Apache will log the message “Failed to read FastCGI header”. The visitor who made the request will see a “503 Service Unavailable” response.
This problem is usually caused by slow PHP code such as slow WordPress plugins. Slow code requires a larger number of concurrently executing processes to handle the same number of incoming requests. Each concurrently executing process uses additional memory.
To resolve the problem, identify the slow app by checking each app’s PHP slow request log.
This problem can also be caused by segfaults (invalid memory access errors) in third-party PHP extensions.
Determine which app is causing the problem
To determine which of the apps on a server is responsible for the resource exhaustion that is causing the error, check the server’s app monitoring dashboards.