HTTP error codes and fixes

Here’s a list with the most common HTTP error codes and solutions for each one.

Error 500: Internal Server Error

Cause 1: Syntax error in .htaccess

Cause 2: Invalid files/directories permissions

Other causes

Errors 502: Bad Gateway & 504: Gateway Timeout

Error 503: Service Unavailable

Error 508: Resource Limit Is Reached

Error 500: Internal Server Error

Error 500
Error 500

Cause 1: Syntax error in .htaccess

Locate the .htaccess file of your host and examine it. Look out for any misspellings. A text editor with syntax highlighting (like vim) will make it easier for you to spot any syntax errors.

Where is my .htaccess file?

The location of your .htaccess file depends on your web server’s setup.

Default Apache .htaccess location: /var/www/html/.htaccess or /var/www/.htaccess

e.g.:

htaccess vim syntax error
htaccess vim highlight syntax error

See that double “i”? The correct command is RewriteEngine, not RewriiteEngine

Fixing it makes the error go away.

Cause 2: Invalid files/directories permissions

Optimal files permissions: 644

Optimal directories perimssions: 755

See this post about fixing the permissions problem.

Other causes

You’ll have to check the error log to spot the culprit of this error.

e.g.:

$ tail /var/log/apache2/error.log
[Timestamp] [core:alert] [pid 10667] [client [IP]:40677] /var/www/domain.com/.htaccess: Invalid command 'RewriiteEngine', perhaps misspelled or defined by a module not included in the server configuration

Errors 502: Bad Gateway & 504: Gateway Timeout

The 502 (Bad Gateway) status code indicates that the server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request.

It is most likely a temporary error. Re-freshing or visiting the site again in a few minutes will probably fix this problem.

Cause

A network problem between the client and the server.

Solution

If this problem persists, check if your server is accessible from any other place. Tools like https://downforeveryoneorjustme.com/ might come in handy. If the problem relies on your server’s side, contact your provider.

Error 503: Service Unavailable

Generally, this error occurs when the web server is either overloaded or under maintenance.

If the error persists, check our First 5 Minutes Toubleshooting a server article and try to spot the culprit.

Error 508: Resource Limit Is Reached

If this error occurs on your website, it is probably caused by a limit imposed on your hosting account by your provider.

Check your account’s stats and usage. This error could be due to many background processes running simultaneously and taking too long to exit (bad code maybe?).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.