{"id":6454,"date":"2021-06-01T20:03:06","date_gmt":"2021-06-01T14:33:06","guid":{"rendered":"https:\/\/www.skynats.com\/?p=6454"},"modified":"2022-12-13T12:37:09","modified_gmt":"2022-12-13T07:07:09","slug":"how-to-fix-the-apache-error-failed-to-read-fastcgi-header","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/how-to-fix-the-apache-error-failed-to-read-fastcgi-header\/","title":{"rendered":"How to Fix the Apache Error &#8216;Failed to read FastCGI header&#8217;?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">On our <a href=\"https:\/\/www.skynats.com\/linux-server-management\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span style=\"color:#056f9d\" class=\"has-inline-color\">server management plans<\/span>,<\/a> our support team will be available anytime to fix all the issues with Apache and FPM.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The issue &#8220;Failed to read FastCGI header&#8221; in your app&#8217;s Apache error log file could be caused by one of three things.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A PHP code error in the software, such as a faulty plugin\/theme<\/li>\n\n\n\n<li>A flaw in a PHP extension that you installed on your server<\/li>\n\n\n\n<li>The server RAM is running out<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The browser will display &#8220;503 Service Unavailable&#8221; when this problem occurs. When Apache connected with PHP-FPM, the error message &#8220;Failed to read FastCGI header&#8221; indicates that the PHP process did not react appropriately.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Fixing PHP Code That Isn&#8217;t Working<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The most common cause of these problems is your app&#8217;s faulty PHP code. The best approach is to disable any WordPress plugins, custom themes, and other custom code until you figure out which code is causing the problem.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The app&#8217;s PHP error log or PHP slow log can provide more details. For each application, it could be in a separate location. The wordpress error log, for example, can be enabled in wp-config.php, and the log file will be located at;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> \/var\/www\/html\/wp-content\/debug.log<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">where &#8220;\/var\/www\/html\/&#8221; is the domain&#8217;s document root, from which the wordpress files are loaded.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If your scripts are slow, for example, a series of difficulties caused by the slow scripts can eventually cause PHP to cease responding to queries. In this case, the solution is to fix the slow PHP code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Troubleshooting PHP Extensions<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One of your custom PHP extensions, such as New Relic or any PECL extension, could be broken. If you&#8217;re using any third-party extensions, follow the steps outlined below to identify potentially malicious PHP extensions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you see the any corrupted in the global PHP-FPM error log file at \/var\/log\/phpX.Y.log, the most likely cause of the problem is a buggy PHP extension crashing PHP. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Disable the Third-Party PHP Extensions for this. If your logs show &#8220;any-extension corrupted,&#8221; you should disable all third-party PHP extensions until you can figure out which one is causing the issue.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To disable a PHP extension, log in as root to your server and disable each extension using this file (the php extension loading file may differ across Apache and Nginx servers; the file location may be found in the info.php file) ;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/etc\/php.d\/extension_name.ini<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Next, restart PHP by running this command as root:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo service phpx.y-fpm restart<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace &#8220;x.y&#8221; with the version of PHP, for example &#8220;7.4&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Memory Is Running Low<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If your server runs out of memory while processing a PHP request and the PHP process is utilising a lot of memory, the PHP process will crash. Look for any issues related to memory usage in the \/var\/log\/syslog or \/var\/log\/messages files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You&#8217;ve ran out of memory if you notice errors like Out of memory: Kill process\u2026 (php-fpm).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, check the free memory available in your server by using ;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>free -g    (or) \nfree -m<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this case, the best approach is to upgrade your server to one with more memory. Reduce the amount of RAM PHP and WordPress utilise as another option.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The PHP process should then be restarted. Even if you haven&#8217;t identified the source of the problem, restarting PHP may be able to restore service to your app.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">SSH into your server as root and perform the following command as root to restart PHP.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo service phpx.y-fpm restart<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are facing any issues with similar errors on your server, Contact our <a href=\"https:\/\/www.skynats.com\/contact-us\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span style=\"color:#026691\" class=\"has-inline-color\">server experts<\/span><\/a> right now to get it sorted.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On our server management plans, our support team will be available anytime to fix all the issues with Apache and FPM. The issue &#8220;Failed to read FastCGI header&#8221; in your app&#8217;s Apache error log file could be caused by one of three things. The browser will display &#8220;503 Service Unavailable&#8221; when this problem occurs. When [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,237,285,224,68,223],"tags":[373,374,375],"class_list":["post-6454","post","type-post","status-publish","format-standard","hentry","category-blog","category-apacha","category-nginx","category-php-8-0","category-server-management","category-ubuntu-18-04","tag-apache-error","tag-fastcgi-error","tag-php-fpm-error"],"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=6454"}],"version-history":[{"count":0,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6454\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=6454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=6454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=6454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}