This guide explores the 500 internal server error code, an HTTP error, and how to fix it.
HTTP Errors and Error Codes
Whenever a web page is loaded, a request is made to an HTTP server (Most web servers run Linux, by the way), and part of the response is a numeric status code that tells your web browser what kind of response it is. This allows the browser to handle the contents of the response correctly.
Some example responses are:
|200||OK – The response was successful, and data has been returned|
|301||The page has been moved permanently|
|404||The page was not found|
|500||Internal Server Error|
The 500 Internal Server Error
The internal server error, status code 500, means that something went wrong on the server hosting the content you are trying to access.
There’s nothing wrong with your web browser or system – it’s them, not you.
The error has occurred due to a programming fault on the software hosting the content you’re trying to view in your web browser.
Even if you were filling out a form and entering unexpected values or interacting with the service in some silly way that breaks it, it’s still not your problem – the programmer who built the site you’re using should have made sure that silly or unexpected behavior from the user was accounted for.
What should you do if you encounter an HTTP 500 error while browsing the internet?
Do you own the website or service showing the error?
Contact the owner of the website – they’ve got some work to do.
You’ve got some work to do.
The good news is that your web server is responding and online – as it’s generating the 500 error and serving it up.
The bad news is there’s an error. If you can see the error’s technical details, the first thing you should do is turn off debugging on your server so sensitive information about your server can’t leak through the error details to the public.
Then, it’s time to inspect your web server logs to see what actually went wrong. The logs and their location will depend on your server environment – which web server you’re using (e.g., Apache or Nginx), and which application environment your code is being served from (e.g., PHP or Python).
Once you’ve found the log entry corresponding to the error, you can begin to fix your code…