HTTP Error 500 Internal server for php pages and solution

Posted on in Categories Apache, lighttpd, Troubleshooting last updated October 24, 2006

You get “500 – Internal server error” error message when a user tries to access your Apache or Lighttpd based dynamic php application (such as forum or blog software).

Generally, to solve this problem you need to take help of log files located at following location:
=> /var/log/message
=> /var/log/httpd/error_logs (/var/log/lighttpd/error_log or /var/log/httpd/error_log)

So you may be wondering why your PHP script throws an Internal Server Error 500.

This error only occurs because of web server software. However after looking through logs you may not find many details. This problem may be caused by:

  • A malformed php cgi script
  • An invalid directive in an .htaccess or other config file
  • Limitation imposed by file system and server software (for example php log file size set to 10Mb)
  • Missing php.ini (or cannot read php.ini file)

In most case it is an invalid .htaccess directive. However recently I came across a web server w/o /etc/php.ini file. A long time ago I setup this server )Apache chrooted jail). So you need to maintain two files one outside jail and another inside jail:
=> /etc/php.ini
=> /chroot/etc/php.ini <-- this file was missingMany scripts open this file on fly to get correct configuration directives. If this file not found you get error 500. It took some time to figure out this problem. Finally strace helped me out to debug this problem.For me it was another day with another interesting problem 😉

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

89 comment

  1. Hello there!
    Please help me solve http 500 internal server error.
    I use Dell Inspiron 6000, Windows Media Center Version 2005.
    The machine was configured to run default web services (on the same machine both server and client) with IIS 5.1. Ran some asp scripts; later php5 is also run and machine’s operation has been satisfactory.
    In the last week of April, an anti virus (corporate licensed version) Kaspersky 6.0.2.678 is intalled. I didn’t use the machine immediately for my php5 / asp work.
    Subsequently the default web server never worked and every time it displayed the above error. Besides, ‘the windows audio tune’ one listens while logging on and off also did not come. all audio stopped working.
    As per advise of some experts, Kspersky Anti Virus has been de-installed/removed–no change; the error persisted.
    The Windows XP Prof is re-installed. The audio has come back but the default web server didn’t.
    Throughout this period the internet web browsing isn’t affected.
    Please let me have your valued help.
    Thanks–cpmresc

  2. I had a 500 result code from a GET of a simple PHPinfo .php file on my Windows Vista install of Apache 2.0 and PHP5. Everything in php.ini, httpd.conf was fine. The error log for httpd complained about:
    “PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0:” trying to open php.ini or something.
    So it’s a permissions problem… but it’s Vista so what to do. Here is what worked after 4 hours of hacking. Open Services control panel, right click on Apache2 service, and change how the service starts/logs on to your Windows logon user. That made PHP module finally click with Apache2. Also, I changed the owner of c:/php to the same user (me) that I changed the httpd service to. Hope this helps save some time for some of you.

  3. Please help me in solving this probelm:
    Am using Dell server with 2003 OS, and Mozilla 1.8.20080.40413 version, I getting 500 Internal Server Error can’t pin point the problem as either refreshing the page or hitting back then clicking on the link again usually makes it appear.

  4. pls help me this problemof mind, my profile in tagged cant open.last nyt i change my bck ground then this is a result my profile is error… pls help me this problem,but i recieve the comment from my friends, i open there id but only my profile i can’t open, pls let me have your valued help. thanx

  5. i recieved this error just now after restarting my windows xp based, apache 2.5.6 wiht php 5.2.6 on index.php file…

    but with index.html is working fine

    and also, phpinfo.php is working 100% fine.

    any suggestion to resolve this issue or refferal guide to.

  6. This happens when there is a PHP error and your php.ini is set to hide error messages.

    There’s 2 ways to handle this:

    1. You have to analyze the Web Server log file. If you run Apache on Linux, it’s usually located at /etc/httpd/logs directory. On Windows, ~Apache_Dir/logs directory. Look at the last few lines of error.log file to find what PHP error occurred.

    2. If it’s a development box, you can set php.ini file as below so it prints error messages on a browser:
    error_reporting = E_ALL
    display_errors = On

    Alternatively, you can put these in .htaccess file:
    php_flag display_errors on
    php_value error_reporting 999999999

    Hope that helps.

  7. can the solution to this problem be put in better english so we can fix it ourselves?

    this problem only occures on my home pc when I try the web site http://www.linkedin.com and I always get the same message ! the rest of the net seems fine!

    its now getting to the point that I will reinstall the entire hard drive to fix it – a bit radical for such a silly problem

    please help someone

  8. hi,
    I am getting 500 Internal Server Error in shared web hosting when i try to insert records in database.
    I am using linux based in shared web hosting with apache 2.5.6 and php 5.2.6 .
    Please help me

  9. Sir , I aslo got http 500 error.i used yahoo web server.i search logfile for the cause.but i do not find any soloution. i do not find my script is caused for this error or server is the guily. i access mysql database 15times/second.i think this is the cause of the error. please guid me throw give me a mail.

    Thanks you in advanse.

  10. I’ve just got this……but what I noticed is it only happens if I’m retrieving over 497 rows from a database on one page……

    I’ve fixed it by adding a LIMIT 450 to the query……. So, I’m now thinking it could be a server/memory/mysql issue?

    php.ini’s memory_limit is set at 35M

  11. i also have the 500 internal error with some comment ” The page cannot displayed, there is a problem with the page trying to reach and it cannot be displayed “, could you please tell me what to do. thanks

  12. hello, i have a HTTP 500 INTERNAL SERVER ERROR.
    I CAN T READ MY EMAILS OR OPEN THEM ANYMORE IN MY YAHOOMESSENGER 9 FOR VISTA
    WHY??? CAN SOMEONE HELP ME PLEASE ASAP
    I HAVE A SONY VAIO WITH A VISTA HOME PREMIUM SOFTWARE
    THANKS ,MARC

  13. GOOD DAY SIR, I HAVE A ERROR MSG ON MY MAIL SAYS ERROR 500 ERROR.
    HAVE TRY BACK OR REFRESH
    I CAN T READ MY EMAILS OR OPEN THEM ANYMORE IN MY YAHOO MAIL
    CAN SOMEONE HELP ME PLEASE ASAP

    BEST REGARDS
    THIAR

  14. One thing you might want to check is the permissions set on the public_html/ directory on a Linux server.

    I’ve had clients set them to 0777 and it causes this error, resetting to 0755 should fix this particular setting.

  15. PEOPLE: a “500 SERVER ERROR” IS ON THE WEBSERVER!!!

    You can’t fix it on your home computer!!

    The software on your home computer — e.g. “Windows Vista Home Premium” — is completely irellevant!!!

    CONTACT THE WEBSITE ADMINS!!!

    It is unusual, but even large web service providers like Yahoo and Google screw things up sometimes and have 500 Server Errors.

    Contact them! e.g. If the problem is on Yahoo Mail, contact [email protected] or similar.

    thank you and good night

  16. As if dial-up isn’t bad enough, all of a sudden I get the 500 error everywhere I have to log in. I can’t make a connection with anything I did lately. Missed a GREAT SHELL-SHOCKER AT NEWEGG…couldn’t log in.

  17. Hi, everyone,

    I think many of you are confused with who should be dealing with these errors. These errors are coming from the server-side, not the client-side. This means that, unless you are the server administrator or something, you cannot correct this error. To have it fixed you should contact the server administrator and have that person examine the server’s error logs.

    I’m working on OS X, running Apache 2, and PHP 5.something. When I encountered this error using AJAX calls I found it was because of a syntax error in my PHP script. How did I find that out? Look at the server’s error log file! It’s very useful information.

    If you have no idea what I’m talking about, then the only thing you can do is complain to the server’s administrator until he/she fixes it. Sorry, bru.

    – Chase

  18. The server encountered an internal error or misconfiguration and was unable to complete your request.
    i get this error when i had run phpinfo(); for test
    please help me send your answer to me by email

  19. Hello,

    Im trying to access my companies intranet from home. But i get the “HTTP 500 Internal Server Error”. The wierd thing is that it works from my sisters computer. We both run windows vista. Can anybody tell me why i cannot access it from my computer?
    I have tried to turn of the windows firewall. did not help

    1. did you get your answer to this and how did you resolve this problem because i get this error on my computers at home, but i can access it on my mobile phone and when i ask my friends they said they can access it. Even my web servers support said they can access it, but i can’t on my end……….i know that 500 error is the web server so how in the world that i am the only one getting this error?

  20. Mine it said something like… highly trained monkeys… I just said WTF and it said to show them a freakin’ code, which apparently i wouldn’t understand. I just reset I.E. and it was fine again… WHAT THE HELL WAS THAT?! And i’m serious i’m telling the truth. If you don’t believe me and the error someday occurs to you, don’t be asking me for what the hell i know….

  21. I NEED HELP FAST AS I GET 500 ERRORS WHEN TRYING TO GET ONLINE BANKING. IF I DONT PAY MY RENT ON TIME IM FUCKED WITH NO HOME. HOW CAN I CONTACT THE WEBMISTER OF THIS SITE? 500 ERRORS is to much for my to handle and microsoft said to call HP but HP said to call this site, do you have a phone number? My bank called me a dick rash but my doctors says I dont have one, maybe thats why my wife left?

    How do I fix these 4004 errors?

  22. I can’t load my page because I get the 500 error after each release. But if I once set the cakePHP debug level higher then 0 (1, 2 or 3) it works properly even if I set it back. I just need to load the page one time in debug level higher then 0 and it works until I release my code again. It’s very strange to me and I don’t understand this problem. Can anyone help?

  23. I NEED HELP FAST AS I GET 500 ERRORS WHEN TRYING TO GET ONLINE BANKING. I can access my personal bank account with no problem. I keep getting this (HTTP 500 Internal Server Error) code when trying to acess my small business account. Can anyone explain this and help me overcome this problem?

  24. i just finished upgrading PHP 5.1 to 5.2 for sugarcrm. Unfortunately the url/website does not update while “click” on user agreement in firefox. My developer told this is due to ownership. please someone help me on this..

  25. hi i keep getting

    This error (HTTP 500 Internal Server Error) means that the website you are visiting had a server problem which prevented the webpage from displaying.

    For more information about HTTP errors, see Help.

    i can only get on the internet via using run as adimistrator i have windows 7 and anysort of internet browser say this i was wandering what this is and how to fix it.

  26. Also, please notice that you might get 500 Internal Server errors if your script is abnormally terminated by the server, due to it needing more than the allowed memory, or execution time.

    You should optimize your scripts not to consume so much memory.
    Until you do this, you could try raising the allowed memory by writing:
    ini_set(‘memory_limit’, ‘128M’);
    at the top of your php files

  27. I have got the 500 error for two days in face book application. .i’m not able to overcome this problem . .and my mobile is Nokia c2-02 . . .please can u suggest anything

  28. Lol! JDS is right. Obviously “you people” are retarded because he/she has posted several comments telling you all WHY none of the other potential solutions from other commentors is not able to fix the problem. Wake up you guys!!! What part of “you can’t fix the problem on your own, you have to contact the web server admin.” do you not understand? Nevermind, you will most likely ignore my comment and continue to try and fix the error on your own anyway. Can’t say I’m all that surprised.

  29. I was running into the same problem in Ubuntu attempting to develop my own .php scripts.

    Oh sure, test.php with the phpinfo function worked just fine but when I tried running my own scripts…BOOM! Server error 500 Hell.

    After having read this page it didn’t exactly tell me what to do but it did point me to the log file which did (contrary to author’s opinion) tell me what exactly the problem was and how to fix it.

    sudo nano /etc/suphp/suphp.conf and make sure the following conditions are true:

    allow_file_group_writeable
    allow_directory_group_writable

    And that seems to take care of it.

  30. hi
    i use from mongodb and it configure on Wamp Server and for useing with php . i add mongo_php.dll in php5.4ext folder and add extension=php_mongo.dll
    in php.ini file but my server not work and occur this error Internal Server Error

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

    Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.

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

    please help me.

Leave a Comment