500 Internal Server Error with no trace?

Hello Experts!

I was wondering if some of you might be able to lend me a hand to find out the cause why I end up with 500 Internal Server errors when I run my php script which transfers photos from another server.

I have run this script and when the error occurs, I check the server error logs and there is nothing registered.  I have PHP error reporting turned on.

How can I find out the cause of these errors?
LVL 17
Who is Participating?
Chris StanyonConnect With a Mentor Commented:
OK. Now we're getting somewhere. Only large files cause the problem! What size is considered large?

You still seem reluctant to show any code, or to isolate the problem, so this is turning into a quiz - each time I ask a question, you give a little more information - we could be at this for days.

Create a script to pull in 1 large file and see if that bombs. cURL has lots of options, so read the manual and make sure you're set up right.

When I say robust, I mean coding in such as way as to deal with issues if they arise (try/catch, error functions etc). I don't think it would necessarily solve your problem, but it would allow better tracking. You might also want to do plenty of var_dumps while debugging your code.

For curl errors, see the curl_error() function:


Turning error reporting on and set to E_ALL will show the errors, but doesn't specify whether to log them. Run phpinfo() on your server and make sure display_errors is ON and error_log is set to a valid path and not commented out. Edit your php.ini file if you need to change the settings.

You can always check if errors are being logged with this:

<?php error_log("Testing the error logging") ?>

Then check your log file.
Lukasz ChmielewskiCommented:
By error logs you mean Apache's error.log ?
OmniUnlimitedAuthor Commented:
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Chris StanyonCommented:
Unfortunately, a 500 Server Error is fairly un-specific, and could be caused by a number of things. Can you run another PHP script (just a basic one) in the same folder? Is there a way for you to comment out some of the functionality of your script, to try and isolate the problem? Are you using htaccess for any rewrites?

If you're not getting any logs in the error files, this is probably easiest solved as a process of elimination.
OmniUnlimitedAuthor Commented:

Thanks for the reply.  I am aware that a 500 server error is fairly un-specific, and could be caused by a number of things, but why wouldn't such an error register in the logs?  I would think that the people who design these things would set up all server errors so that they would log.

The problem with your idea of commenting out some of the functionality of the script is that I am not getting any error messages on the server, so isolating the area where the problem is does me no good as far as helping me to determine the cause (I know which part of the script is causing the problems, BTW).

This is just a one page function to draw images from another server.  .htaccess is not involved.
Chris StanyonCommented:
If the error is critical, it may break the server enough that it's not able to write to the logs.

If you know which part of the script is causing the problems, then you're half way there. Post up the problem code and we'll have a look.
OmniUnlimitedAuthor Commented:

While I understand completely your desire to see the code (I am certain you are assuming the problem lies in the code), you should know that what is happening is that the script is breaking in the middle of an echo statement.  It prints out part of the text (which is a url for debugging purposes) and then breaks with an
Internal Server Error.  

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, non@na.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Open in new window

You should also know that upon repeated runs of the script, the break point is not consistent, i.e. it will break in different points along the string.

Therefore, I need to clarify what it is that I was saying when I said, "I know which part of the script is causing the problems"  I meant to say that "I know where in the script the program is breaking" not, as I erroneously stated, where the problem is occurring.
Chris StanyonCommented:
Hey OmniUnlimited,

If you can run another script on your server in the same folder, then it's highly likely that your current script is breaking and causing the 500 error (nowhere in the error you posted mentions 500). If you can't run another script then maybe it's a server issue.

PHP parses a document fully before outputting to the browser, so it does seem odd that you're getting part of an echo statement out. Normally, a 500 error happens and PHP won't output anything.

It does mention that the problem is on the na.com server. Is this your server, or the remote one you're trying to pull data from.

Without seeing code, I could spend all day just guessing, so unless you can post code for us to test, there nothing else I can do.

As I said, you could try isolating parts of your code to see if that solves the problem. If your code is written robustly enough to handle unexpected errors, then you should be able to resolve it.
OmniUnlimitedAuthor Commented:
Hey ChrisStanyon:

nowhere in the error you posted mentions 500

The text of the error message is the stuff that appears on the web page.  The browser title bar is where I see the "500 Internal Server Error".

If you can't run another script then maybe it's a server issue.

I can actually run to completion the script that keeps breaking if the amount of the data I am pulling from the other server is small.  I am using curl to pull the image files and the echo statement that gets cut off is found on the line just before the curl statements.  I am thinking that somehow in the pulling of information from the other server something is happening to cause the error and stops the output of the script in mid-stream.  Do you know of a method that will allow me to see errors that occur during a curl file access?

Is this your server, or the remote one you're trying to pull data from.

The email address is from my server.

If your code is written robustly enough to handle unexpected errors, then you should be able to resolve it.

I have error reporting turned on and set to E_ALL, yet I still get no record of any errors in the log.
OmniUnlimitedAuthor Commented:
Perfect!  In following your instructions and making the script more robust, and activating error reporting and an error log path in php.ini, I was able to achieve logging of the events which pointed me to a misconfiguration in the mod_fcgid file.

Thanks a million.
Chris StanyonCommented:
Glad you got it - debugging is sometimes a bit of a dark art :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.