http error

How to Fix WordPress HTTP Errors?

HTTP error codes are not easy to understand at first sight. Seeing your WordPress down without knowing why and what to do is a particularly unpleasant feeling.

Thank God, WordPress is such an amazing CMS that the most common HTTP error codes can be fixed easily.

In this guide, I’ll explain you what are HTTP error Codes and how to troubleshoot HTTP errors on WordPress. If you are currently viewing this page your site is maybe offline, so let’s go!

HTTP Error Code: summary of everything you need to know

Internet is based on a protocols of communication between web serveurs and computers.

When someone attempts to reach your website, he send a request and the server ALWAYS returns corresponding status codes.

There are 5 categories of HTTP response status codes. They are made of three number. The first number define their category:

1xx status codes provide you with information about your request processing.

2xx status codes mean that your request is successful.

3xx status codes are redirection status codes.

4xx status codes refer to client errors.

5xx status codes refer to serveur errors.

It is not necessary to know the list of all HTTP error status codes. This is useful only if you want to understand how the client/server relationship actually works.

If you are in a hurry, just look at the explanation of the error code displayed by your browser, then go to the troubleshoot section.

I wrote this guide to assist those who aren’t server managers or web developers. It’s 100% beginner friendly.

HTTP Error codes and what they mean

1xx Status codes

There are informational response codes. They mean that the server received the request and is processing it.

  • Status code 100 #Continue: The request has been received by the server. A final response will be provided after the request has been fully received.
  • Status code 101 #Switching Protocols: The server will process the client’s request.
  • Status code 102 #Processing: The serveur is processing the request, but no response is available yet.

2xx Status codes

They indicate that everything is fine! The server accepted the client’s request and is dealing with it.

  • Status code 200 #OK: The request has succeeded. Easy.
  • Status code 201 #Created: The request has been accomplished. Additional ressources are being created by the serveur.
  • Status code 202 #Accepted: The request has been accepted for processing and the processing is still going on. The 202 response purpose is to allow a server to accept a request for some other process without requiring that the user agent’s connection to the server persist until the process is completed.
  • Status code 203 #Non-authoritative Information: The returned information is not exactly the same as is available from the origin server. Status code 203 might happen if you use CDN or a proxy.
  • Status code 204 #No Content: The request has been processed and that there is no more content to load.
  • Status code 205 #Reset Content: Tell the user to reset the document which caused the request to be sent.
  • Status code 206 #Partial Content: The server is successfully fulfilling a range request for the client but will only transfert part of the ressources.
  • Status code 207 #Multi-Status: Provide information about multiple resources, for situations where multiple status codes might be needed.
  • Status code 208 #Already Reported: Used to avoid repeatedly enumerating the internal members of multiple bindings to the same collection. Prevent your serveur from entering into endless loop.

3xx Status codes

3xx HTTP status codes are redirection codes. They inform that further action is needed. SEO friendly redirections work with 301 HTTP status codes for example.

  • Status code 300 #Multiple Choices: The request has more than one possible response. The user has to choose one of them by redirecting its request to the best identifier(s).
  • Status code 301 #Moved permanently: The URL of the requested resource has been changed permanently. The new URL is given in the response. 301 Redirection are SO important for SEO. Read this guide from Theme island if you want to know more about it.
  • Status code 302 #Found: This means that the URI* of requested resource has been moved temporarily.
  • Status code 303 #See other: The server sent this response to direct the client to get the requested resource at another URI*.

What does URI means?

URI stands for Uniform Resource Identifier. URI refers to things such as ‘https://’ or ‘mailto:’. Check out this article if you want to know more about it. If you don’t, just consider URI as URL.

  • Status code 304 #Not Modified: The request has been received and would have resulted in a 200 OK response, but the condition was evaluated false.
  • Status code 305 #Use Proxy: Indicate that a requested response must be accessed by a proxy. It’s highly likely that you will never encounter 305 error nowadays.
  • Status code 307 #Temporary Redirect: The server sends this response to redirect the client to the requested resource at another URI with same method.
  • Status code 308 #Permanent Redirect: The resource is now permanently located at another URI. 308 status codes are similar to 301 status code.

4xx Status codes

4xx Status codes indicate a problem from the client (or the browser) side. In other words, 400 errors are not coming from the serveur.

  • Status code 400 #Bad Request: The server can’t process the request due to invalid syntax.
  • Status code 401 #Unauthorized: The request was not authorized because it lacked valid credential.
  • Status code 403 #Forbidden: 403 errors are similar to 401 errors. The difference is that the client is recognized by the serveur, but the access is denied.
  • Status code 404 #Not Found: The famous 404 error! The server couldn’t find a representation for the target resource. 404 error status code mostly happen when you misspell an URI.
  • Status code 406 #Not acceptable: They happen when the web server doesn’t find any content that meets the criteria given by the user.
  • Status code 407 #Proxy Authentification Required: not much to say. The client needs to authenticate itself to use the proxy. It’s very much alike 401 status code.
  • Status code 408 #Time out: The server didn’t receive a complete response within the time that it was prepared to wait. Nowadays, Internet Explorer, Chrome and Firefox use HTTP pre-connection mechanisms to improve user experience and loading-time. It results in a higher number of 408 status code.
  • Status code 409 #Conflict: The request could not be completed because of a conflict with the state of the target resource.
  • Status code 410 #Gone: The resource is no longer available and this condition is likely to be permanent. 410 Status code are similar to 404 status code. 404 status code is returned when the server doesn’t know if the condition is likely to be permanent.
  • Status code 411 #Length Required: The request is rejected because the Content-Length is not defined and the server requires it.
  • Status code 412 #Precondition Failed: The client has indicated preconditions and the server doesn’t meet them.
  • Status code 414 #URI Too Long: All is in the title. The URI requested by the client is too long and the serveur refuses to process it.
  • Status code 415 #Unsupported Media Type: The media format is not supported by the server. Thus the server is refusing to process the request. 415 are often the consequence of an encoding problem.
  • Status code 421 #Misdirected Request: The request is sent to a server that isn’t able to produce a response. It occurs when server is not correctly configured.
  • Status code 423 #Locked: The resource that you want to access is locked.
  • Status code 424 #Failed Dependency: The action requested depended on another action that have failed.
  • Status code 429 #Too Many Requests: Too many requests were sent over a short period of time.

5xx Status codes

This category of status Code refers to internal server errors. They occur when a server is not able to accomplish an apparently valid request. They sometimes can be caused by plugins.

  • Status code 500 #Internal Server Error: The server encountered a situation and doesn’t know how to deal with it.
  • Status code 501 #Not implemented: The request method is not supported by the server and cannot be processed.
  • Status code 502 #Bad Gateway: The server, while working as a gateway to get a response got an invalid answer and can’t process the request.
  • Status code 503 #Service Unavailable Error: this indicate that the server is temporarily unable to process the request. It happens when the server is overload because of traffic spike or down for maintenance. If you encounter too many 503 errors, you should really consider getting another web host.
  • Status code 504 #Gateway Timeout: The server, while acting as a gateway or proxy, did not receive a response in time.
  • Status code 505 #HTTP Version is not supported: It means that the HyperText Transfer Protocol version used in the request is not supported by the server.
  • Status code 506 #Variant Also Negotiates: The server configuration doesn’t allow the operation to go further.
  • Status code 507 #Insufficient Storage: The action was not processed because the server wasn’t able to store the representation needed to perform the request.
  • Status code 508 #Loop Detected: The server encountered an infinite loop while processing a request. Always make sure that your loop are closed.
  • Status code 511 #Network Authentication Required: This indicates that the client has to authenticate to correctly access the network.

Troubleshooting HTTP Error Codes on WordPress

Nota bene: before trying to fix an HTTP error, you should ALWAYS make a backup of your WordPress Website (FTP + Database).

How to Fix 400 Bad Request Error on WordPress?

What is 400 Bad Request Error?

The 400 Bad Request Error indicates that the server was unable to process the request due to invalid syntax. It falls into the Client Error category. 400 Bad Request error happen before it is even processed by the server.

Main causes of 400 Bad Request Errors

Errors 400 can have a multitude of reasons, but here are the most common ones:

Uploading a too big file: to protect your bandwidth, many web servers (almost all of them) limit by default the size of the files your visitors can upload. When such an upload occurs, the server returns a 400 Bad Request error.

Sending a request to an invalid URL: sending a request to an invalid URL (ie: with erroneous characters, malformed syntax or illegal characters) can return a 400 Bad Request Error.

Expired/wrong cookie: Sometimes your browser can store invalid or expired cookies. The server may perceive this cookie as dangerous and return the 400 Bad Request Error code.

Troubleshooting the 400 Bad Request Error Code (soon)

How to Fix 500 Internal Server Error on WordPress?

The 500 internal serveur error is probably one of the worst you can get because your entire site is down. So, we will start here.

On WordPress, 500 internal serveur errors are very often the consequence of an error in the PHP code.

But you never wrote a single line of code, so how could an error like that happen?

Every time you add a theme or plugin to your WordPress, you are actually adding lines of code.

This can, among other things, crash your entire WordPress Website.

This is how to fix 500 Internal Server Error on WordPress:

1. Manually Remove plugins and themes

It is likely that the 500 error you are encountering is a consequence of the last theme or plugin you installed or updated. So, the first thing to do is to remove them.

How to manually remove a plugin or theme if my website is down?

Easier said than done because your site is down and you can’t access WordPress Admin Dashboard so how do you do that?

You first need a FTP Client. I personally use Filezilla. The software if free and safe.

To use Filezilla and connect to your website, you will need to enter your FTP adresse, username and password.

If you don’t know your credential, then check the first emails your hosting company sent you when you signed up. It usually contains your FTP username and password. If you don’t find it, reach out your hosting support.

Once you are connected, you need to go to /www/wp-content/plugins/ folder.

Then click right on your plugin, and click on delete. Erase one plugin, go back to your browser web and open a private navigation window.

If this doesn’t work, go to the next step!

2. Restore a corrupted .htaccess file

Sometimes, plugins and themes can also corrupt your .htaccess file, causing 500 Internal Server Error.

In order to restore your .htaccess file your need to access your WordPress Root directory with your FTP Client (see above).

Then, download the file named .htaccess and open it with your favorite HTML editor.

Delete the contents of the file and copy/paste the code below instead.

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Reload your website to see if the 500 internal server error is fixed. If it is not, then navigate to the next step.

3. Increase your PHP Memory Limit

Another way of fixing the 500 internal server error is by increasing the PHP Memory Limit in WordPress.

To increase your PHP Memory Limit in WordPress you need to edit the function.php file by adding these 3 lines of code:

@ini_set(‘upload_max_size’ , ’64M’);
@ini_set(‘post_max_size’, ’64M’);
@ini_set(‘max_execution_time’, ‘300’);

Function.php is located in your root directory.

You can access and edit the file with your FTP client in the same way as the htaccess file (see above).

How to Fix HTTP Errors When Uploading Images in WordPress?

HTTP errors sometime occur when you try to upload a media in the Library. These errors can be hard to troubleshoot.

Unlike browser errors, where you can get the full HTTP status code, and quickly identify what went wrong, WordPress only returns “HTTP error” when you attempt and fail to upload a media.

The only information you can get about the error is the error itself. No error log, no status code, nothing.

To tackle an HTTP error on upload, it’s therefor necessary to eliminate step-by-step every possible error. Here is what you need to do:

1. Refresh the page and clean your browser cache

Sometimes, the easiest solution is the best. Why refreshing the page in your browser?

You might have lost your connection temporarily during the upload, or your web host might have encountered a very brief downtime that prevent the serveur from processing your request.

Your login session maybe expired or you have perhaps tried to upload so many images and overloaded your serveur. Whatever, many HTTP Errors (401, 408, 429, 503, etc.) are often temporary.

Push F5 (Window) or cdm+R (Mac) and try to upload your media again.

If it doesn’t work, clean your browser cache (cdm+shift+R on mac) and try it again before going to the next step. You might have to login again.

2. Resize the file and increase the WordPress maximum upload file size

HTTP errors can happen if your file size is too big. Reducing media size should be a top priority anyway. It’s an excellent way to improve your user experience (UX) and your ranking in Search Engines (SEO).

There are a lot of image optimization plugins that can automatically do this for you when you upload something to the media library.

I personally use (and recommend) Imagify, but Smush and ShortPixel are excellent too.

If resizing your media doesn’t work, you should try increasing your the maximum upload file size in your WordPress Settings.

3. Rename the media before uploading it

A media upload can fail because of its name. Try to avoid accent and strange character such as language symbols or apostrophes in your file names.

You also have to check that your filename is original and doesn’t not already exist.

If you are lazy to rewrite your file names, the plugin Image SEO Optimizer uses Artificial Intelligence to do it automatically.

It’s also good for SEO.

4. Deactivate every plugin and theme

Themes and plugins can cause many HTTP errors and slow down your WordPress Website.

Start by deactivating every plugins and themes and upload again the file responsible for the HTTP error.

If the error remains, you can reactivate all your plugins and themes. I would however encourage you to use this opportunity to remove the plugins and theme that you are not using. It might speed up your website.

If the error vanished, activate one plugin and try upload the image. Repeat the operation until you find the plugin or theme that was causing the HTTP error and reach out their support.

5. Increase WordPress PHP Memory Limit

The PHP Memory Limit is different of the maximum upload file size. Increasing PHP memory available for WordPress to use might fix your HTTP error.

To increase your WordPress PHP Memory Limit you have to add this piece of code to your wp-config.php file.

define('WP_MEMORY_LIMIT','256M');

It should be totally enough to fix any PHP memory limit issues.

6. Update WordPress PHP version if necessary

You should alway use the last PHP version available. If you are not using the last version of PHP, I recommend you to update it. It’s better for your website security and performance.

You can probably update your PHP version in your web host admin panel. If you don’t find the option, shoot an email to the support.

Note that WordPress Managed hosting are supposed to always be up to date. Check out my post WordPress Hosting: A Step-by-Step Guide for 2020 if you want to know more about it.

7. Use GD Library instead of Imagick

WordPress uses two different PHP module to deal with images: Imagick and GD Library. Both of them are safe and well-functioning.

However, Imagik is more greedy in resources than GD Library, which can lead to WordPress HTTP errors if you are using a shared web hosting.

To switch from Imagik to GD Library you have to copy/past this code to your function.php file.

functionwpb_image_editor_default_to_gd( $editors){
$ gd_editor= 'WP_Image_Editor_GD;'
$ editors= array_diff( $editors, array( $gd_editor) );
array_unshift( $editors, $gd_editor);
return$editors;
}
add_filter( 'wp_image_editors', 'wpb_image_editor_default_to_gd');

If switching from Imagik to GD Libary didn’t fix your problem, make sure you delete the added code above from your files.