Search code examples
phpmagentointernal-server-error

Magento - Internal Server Error on external request


I'm using a system that downloads the products from Magento and then it can post to eBay etc. However, when I start the sync process where it is accessing the Magento (API connection verified and working), it throws an Internal Server Error. the Error log shows:

[Thu Dec 04 14:25:15 2014] [warn] [client IPADDRESS] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server [Thu Dec 04 14:25:15 2014] [error] [client IPADDRESS] Premature end of script headers: index.php

I was told this was a server error but can't find out what is the cause or how to fix. Any tips would be much appreciated.


Solution

  • There are multiple problems here. The first problem is that the FastCGI server is timing out. To remedy these, there are certain directives you need to adjust but without knowing your server I can't tell where you need to add them. It would either be in a vhost.conf file for the domain, the main httpd.conf file for the webserver or a server administration tool like Plesk:

    <IfModule mod_fcgid.c>
        FcgidIdleTimeout 80
        FcgidBusyTimeout 300
        FcgidIOTimeout 300
    </IfModule>
    

    EDIT: If you're using Plesk, go to Domains > example.co.uk > Websites & Domains > Web Server Settings. In here you'll see a textarea labelled "Additional directives for HTTP" where you can drop the above directives in. Press OK at the bottom of the page to save them and restart Apache

    Secondly, your PHP script is running out of memory. 134217728 bytes is about 134 MB. You can try increasing this by inserting this line at the top of the script:

    ini_set('memory_limit', '256M');
    

    That will increase the memory limit for the script to 256 MB. If that doesn't work then you may need to increase it even further until the script has enough memory to complete.

    There are different ways to change the memory limit. If you change it in the php.ini file I believe the server will need to be restarted. Since you're using Plesk, you might be able to increase the memory limit in there:

    Go to Domains > example.co.uk > Websites & Domains > PHP Settings. The first setting should be memory_limit where you can enter a custom value

    Web Server Settings and PHP Settings for the domain are found here:

    Screenshot of Plesk Web Server Settings and PHP Settings location