Fix - php-cgi.exe quits after exactly 500 hits on Windows or 502 bad gateway errors

I had this issue on Windows.

I fixed it after reading two threads on stackoverflow.

My current Caddyfile is:

:2015 {
	root C:\sites\1
	on startup php_cgi.bat &
	fastcgi / php


	C:\php\php-cgi.exe -b 6545

Another option if you’re worried on memory leaks in php_cgi.bat:

    C:\php\php-cgi.exe -b 6545
    goto start

Other suggestions in these stackoverflow issues may work too, but this works for me on Windows 7 x64.

Though I would share it in case someone finds it helpful.

@ITSecMedia and @pwhodges you may find it helpful.

@matt I suggest adding a note on it in the docs. Maybe here:


@Whitestrake, @tobya, @Alan_Bradshaw I think you may find this thread helpful.

1 Like

cheers magikstm :wink: