IIS and PHP error 500, "The parameter is incorrect. (0x80070057)" in FastCgiModule

Max Mayer 0 Reputation points
2023-07-06T11:34:15.2633333+00:00

I have PHP 8.0.28 in IIS 10.0 (Windows Server 2022), the fastcgi module is configured correctly and working as it should in most cases, but sometimes I get 500 error when I make a request, even for the same url requested in the most of the time it responds with a 200 status, but sometimes it responds with a 500 error. This instability makes me think of a bug either in PHP or in IIS or in the way they communicate.

Unfortunately no errors appear in the OS events, nor does PHP catch any errors, I was able to get information about the error using IIS tracing.

Internet Information Services
{count} votes

3 answers

Sort by: Most helpful
  1. Yurong Dai-MSFT 2,836 Reputation points Microsoft Vendor
    2023-07-07T08:08:07.4033333+00:00

    Hi @Max Mayer,

    Please check the IIS logs for any information about the 500 error. The logs can be found in the default location: %SystemDrive%\inetpub\logs\LogFiles.

    If you have enabled Failed Request Tracing (FRT), FRT will provide detailed information about request processing, including any errors or warnings encountered. The failed request log files can be found in the default location: %systemdrive%\inetpub\logs\FailedReqLogFiles\W3SVC.

    Also, intermittent 500 errors may be caused by resource exhaustion. You can try monitoring server resources such as CPU, memory, and disk usage with tools like Performance Monitor (perfmon) or Resource Monitor to analyze resource usage at the time the error occurred.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the email notification for this thread.

    Best regards,

    Yurong Dai


  2. MotoX80 35,226 Reputation points
    2023-08-20T15:56:16.5933333+00:00

    I don't see anything useful in the XML data. You can also check in the HTTP error logs.

    C:\Windows\system32\LogFiles\HTTPERR

    If this is an intermittent error, then to me that would indicate that it is data or activity related.

    Check the request monitor and look to see if you have a large number of requests that are executing. You might also have a request running that is locking some backend database table which impacts the site. Have your database team check the activity in the DB instance.

    https://inthetechpit.com/2019/11/10/check-incoming-requests-iis-with-request-monitor/

    You can also check that from a "run as admin" powershell prompt.

    Get-Website | Get-WebRequest | format-table -property Hostname, timeElapsed, clientIpAddress, Url
    

    Have your web site developer check the PHP code for the page that crashes the most, and make sure that there is a try/catch code block that will capture any error. Write any error back to the client and also to a log file. See if you can pinpoint the call/statement that crashes.

    You can also open the XML file with Edge and then reload the page in IE mode from the menu to look at it formatted. You might see something there.

    User's image

    User's image


  3. Max Mayer 0 Reputation points
    2023-08-20T23:16:42.6933333+00:00

    Finally I managed to figure out what the problem is, the PHP opcache module evidently has a problem with shared memory and when the number of visits increases, the server crashes

    Faulting application name: php-cgi.exe, version: 8.0.28.0, time stamp: 0x63eb7b04
    Faulting module name: php_opcache.dll, version: 8.0.28.0, time stamp: 0x63eb7e4f
    Exception code: 0xc0000005
    Fault offset: 0x0000000000168011
    Faulting process id: 0x1f2c
    Faulting application start time: 0x01d9d3b2249e086e
    Faulting application path: /path/to/php-cgi.exe 
    Faulting module path: /path/to/php_opcache.dll
    

    Thanks for your help


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.