Solved

500 Internal Server Error with no trace?

Posted on 2013-11-14
11
634 Views
Last Modified: 2013-11-21
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?
0
Comment
Question by:OmniUnlimited
  • 5
  • 5
11 Comments
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 39648912
By error logs you mean Apache's error.log ?
0
 
LVL 17

Author Comment

by:OmniUnlimited
ID: 39649090
Yes.
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39649705
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.
0
 
LVL 17

Author Comment

by:OmniUnlimited
ID: 39649875
@ChrisStanyon:

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.
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39649892
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.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 17

Author Comment

by:OmniUnlimited
ID: 39650134
@ChrisStanyon:

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.
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39650614
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.
0
 
LVL 17

Author Comment

by:OmniUnlimited
ID: 39650902
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.
0
 
LVL 42

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39650957
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:

http://us2.php.net/curl_error

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.
0
 
LVL 17

Author Closing Comment

by:OmniUnlimited
ID: 39666787
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.
0
 
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39666937
Glad you got it - debugging is sometimes a bit of a dark art :)
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Ubuntu 16.04 AMD video card driver issues 20 104
a free alternative to cpanel? 1 37
Phone Dialer 5 36
Wordpress Body Class 5 9
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now