What is Error Code 500 on my server?
When your server, whether dedicated or VPS, is throwing Error Code 500, there’s a misconfiguration issue that’s stopping the normal 200 Success messages you’d love to be seeing instead.
Some 500 errors can be caused by the webserver itself due to invalid lines in say .htaccess.
Other times, 500 errors can be caused by broken PHP code.
Browser status codes can tell a lot about resources being requested from a server. When the browser asks for pages that are missing, 404’s are expected. When requesting a page that’s been moved to a new URL, a 301 redirect is at the helm, until you arrive at the working destination page, like all other working pages, where you hope to get a 200 status code.
500 Error Code is a blanket, "Oops" message that tells us the server isn't working as expected.
Error Code 500 is also known as 500 Internal Server Error and can come from a variety of causes.
Getting More Information via Logs
On a shared or reseller plan at KnownHost, you’d be able to login to cPanel and see the error logs report within that friendly user interface.
For VPS and dedicated users, you’ll be able to check the error logs, which are located in:
cPanel domain access logs and error logs can be found:
Getting More Information via Debugging
PHP debugging can tell a lot more about what’s going on, if enabled, which requires a couple of configuration changes. Debugging can be enabled for individual pages, like index.php or globally by enabling using php.ini. It can also be enabled for particular applications, such as WordPress, by editing the wp-config.php file.
Method #1 – Enable Debugging via php.ini
With this approach, adding 3 lines to the php.ini file will turn on debug messages. Just remember to undo this change, otherwise a load of error information will be appearing across website pages of the site. Make a copy of your php.ini file before making these changes.
Method #2 – Enable Debugging via index.php
Rather than editing the php.ini file, just add this line to the top of your index.php. Whenever the site homepage loads, error messages should be clearly visible. Make a copy of your index. php file before making this change. You’ll see exceptions flying once it’s changed.
Method #3 – Enable Debugging via WordPress wp-config.php
If you’re wanting to troubleshoot a WordPress-based site, then you can use the debugging information provided by WordPress debug mode. Make a copy of your wp-config.php file before editing, just in case! Enabling debugging is a one-liner. After making this change, keep an eye out for fatal errors.
define( "WP_DEBUG", true );
Errors, even simple syntax errors, in the .htaccess file can cause the web server to throw errors, particularly 500 Error Code.
Open the file, visually inspect and correct any issues found. Particularly suspect would be any recent additions or changes to it.
This would be a good time to make a copy of the current .htaccess and consider replacing it with a known good backup version of the file.
Alternatively, by temporarily renaming the .htaccess to something like .htaccess-old, you could get a chance to reload a web page and see how it behaves without any .htaccess influence at all (something handy if your backup isn’t really a known good backup at all).
Running out of memory is one way to get either the dreaded “Allowed memory size” error, or a 500. Low available memory can also cause program execution to slow enough that timeouts occur – again with a 500 as a result.
Editing the php.ini file in your public_html folder, you can increase available resources:
memory_limit = 128M
Consider increasing the number up to 256M and see how it performs then.
There’s no being stranded when you’ve got fully managed dedicated or VPS hosting at KnownHost. If you’re stuck and still having an issue, want to discuss or get a hand, simply open a ticket with technical support and you’ll get answers, fast!