What is error 400?

What is 400 error code?

The HTTP 400 status code, also known as "400 Bad Request," is a client-side error response code that indicates the server cannot process the request due to a problem with the request itself.

“400 Bad Request” is a general error that indicates that your browser sends a request to the website’s server and the server can’t process or recognize the request. The following article will explain what is the “400 Bad Request” error, the most common causes, and how to fix it.

The causes of the “400 Bad Request” can be various, but usually, they are related to a local issue on your browser or device. In rare cases, the error may be caused by a misconfiguration in the website’s hosting server. In the next section, we will examine the most common cases.

What are the most common causes of the “400 Bad Request” error?

As we examined so far, the most common causes of the HTTP Error “400 Bad Request” are related to a local problem from your device or browser and, in rare cases – a misconfiguration on the website’s server. These can be: expired cookies, syntax errors in the URL, outdated cache from your browser, file size limits when uploading a file, unsynchronized DNS cache from your device, or a server-related error.

URL String Syntax Error

This is a very common cause of a “400 Bad Request” error, and it is associated with the syntax of the address you are typing in your browser. The error indicates that the requested URL doesn’t have a valid structure or contains invalid characters which the web server is not recognizing as part of a valid URL address.

Below, you can see an example of an URL with a syntax error:

https://www.nexonhost.com/support/kb/%%404_not_found_error/

In this example, the error is triggered by the double “percentage” sign (%) in the URL structure. Web servers do not permit URLs containing two consecutive special characters, and the part “%%” is causing the web server to respond with a “400 Bad Request” message.

In this example, the error is triggered by the double “percentage” sign (%) in the URL structure. Web servers do not permit URLs containing two consecutive special characters, and the part “%%” is causing the web server to respond with a “400 Bad Request” message.

Corrupted Browser Cache & Cookies

In order to improve user experience and loading speeds, most popular browsers store data from previously-visited sites in the form of cached files and cookies.

The cached data allows you to reload faster as the browser has already downloaded files from the site locally on your computer and doesn’t require time to download them again from the server. Such files include:

  • Media – video and image files
  • HTML files
  • Data files – JSON, XML
  • JavaScript files
  • CSS files

The saved cookies, on the other hand, store information from previous sessions on the site. For example, if you logged in previously on the site, the browser will save the login details for this site and will allow you to stay logged in for a longer time, even if you closed the browser tab. A website can use many cookies for the different functions it offers to visitors.

Those browser’s features are extremely useful, but if your browser has saved corrupt or outdated files or cookies with expired information, your next request to visit the site may not be correctly recognized by the web server.

Browser extensions and plugins

Occasionally, you may see the error “400 Bad Request” on Chrome, Firefox, Safari, and other browsers due to an installed extension interfering with the connection to the website.

Unsynchronized DNS Cache

User experience and speed are also improved by the local DNS cache from your device or network. Previous DNS lookups are cached, so next time you type in a website URL, the website domain’s DNS settings are directly loaded from the local DNS cache, saving loading time. However, if your local cached DNS settings are out-of-sync or outdated and the domain’s DNS settings have been changed, your browser may return the HTTP error “400 Bad Request”.

Incorrect file size

Another common cause of the “400 Bad Request” error is the server limits for the file sizes of uploaded files. It is a common practice for web servers to have a specified maximum size of uploaded files on a website they host. The most common case is: you upload a file to a website, the upload takes quite a long time, and finally, you receive the error “HTTP Error 400 Bad Request”. Simply, the file is too large and hits the file size limit on the website’s server, so the server responds with the error code.

Website misconfigurations

This is not a common cause, and it is highly unlikely, but sometimes the problem may stem from an unidentified misconfiguration of the website.

How to fix the “400 Bad Request” Error?

Now that we outlined the most common cases of the “HTTP Error 400 Bad request “, it is time to examine the most common fixes for each of the causes.

Double-check the domain address

DNS (Domain Name System) is the system that translates user-friendly website names (domains) to server IP addresses. Thus, visitors don’t need to remember long strings of digits but instead use an easy-to-remember name to reach your website. Valid domain names are formed only from letters and very few special characters – fada characters (acute accent) and hyphens (dash). The domain name can’t exceed 63 characters, can’t have empty spaces, and can’t start or end with a “hyphen”.

Examine the URL of the website, and check if you have any other type of special character or empty space in the domain part of the URL. If the address is missing a forward slash after the domain, this may be the cause of the “HTTP 400 Bad Request” Error.

Check the submitted URL

As we also pointed out, a malformed URL with incorrect syntax and structure can also trigger an “HTTP 400 Error Bad Request” response from the server. If you enter an URL manually, it is quite possible to accidentally enter illegal characters or extra special characters that the web servers do not recognize.

Earlier, we used an example of an invalid URL:

https://www.nexonhost.com/support/kb/%%404_not_found_error/

The part of this URL causing the “HTTP 400 Error Bad Request” is “%%”. It is permitted to have special characters in the URL, like “%”, but two or more consecutive special characters are considered an invalid format by the web servers, and they will return the “Bad Request 400″ error. Also, pay attention if the URL contains “unsafe” and “unwise” characters, such as “$” , “[” , “]” , “|”. After inspecting the URL, test removing such characters from the URL string. There are many useful online URL encoder/decoder tools that can help you analyze the URL string and detect illegal characters. You may consider this online tool.

Clear browser cache or cookies

As we examined, the browser cache is a very common cause of the “HTTP Error 400,” and it is mostly related to outdated or corrupt cached files and saved cookies. All browsers provide the option to clear their cache and cookies. Depending on your preferred browser, the option is reached from the browser’s specific menus. For detailed steps, read this guide on clearing cache and cookies on different browsers.

For clearing the cache on mobile devices, choose one of the articles below:

  • How to clear the cache on Android
  • How to clear the cache on iPhone

Another way to examine if the origin of the error is your browser cache is to test accessing the site from your browser Incognito/Private window mode. Those modes don’t save cache or cookies, and if you are able to open the requested page, it means that your browser cache is the culprit.

Turn off browser extensions

We discussed the more popular and obvious causes of the “HTTP 400 Error Bad Request”. However, there are cases when the error may be triggered by a specific extension installed in your browser. Some extensions’ specific functions may affect the cookie sessions between your browser and the visited site, thus triggering the “HTTP 400 Error”.

Let’s take Chrome as an example. Click on the kebab menu on the top right, choose More Tools, and select Extensions.

You will load the Extensions page listing all installed extensions in your Chrome browser. Test by disabling your installed extensions by turning off the slider for each one.

If the error is gone after deactivating a specific extension, you can conclude that it is affecting your connectivity to the site.

Flush the DNS cache

Unsynchronized local DNS cache from your device is also a common reason for the “HTTP 400 Error Bad Request”. The DNS cache can be cleared from your OS (operation system). Read the following guides on how to clear the DNS cache on your OS:

  • How to flush the DNS cache on Mac OS
  • How to clear the DNS cache on Windows
  • How to flush the DNS cache on Linux

Check the file size

Another cause of the “HTTP 400 Error Bad Request” is the size of files you are uploading on a website – like video, images, audio files, etc. If the uploaded file exceeds the maximum upload file size on the server, it will respond with “HTTP 400 Error Bad Request”. You can test by uploading a smaller file to determine if the file size of your original file is too large. If the test with the smaller file is successful, it means that the original file is too big. You may consider compressing the file to reduce its size with an application on your local device or with an online compression tool.

Check your internet connection

If you followed all troubleshooting steps as described above but you still encounter the “HTTP 400 Error Bad Request”, you may also consider the possibility of connectivity issues coming from your network. In order to test, switch your internet connection. For instance, if you use a Wi-Fi/cable network, switch your device to a mobile 3G/4G/5G network. If the error is gone, you can conclude that the error is coming from your network or ISP (Internet Service Provider). In this case, you may consider restarting your Wi-Fi/cable modem or router or contacting your ISP so they can investigate the origin of the connectivity issue.

Contact the website administrator or the hosting provider

If none of the above methods are working and other visitors using different networks experience the same error, it is safe to assume that the origin of the error is a misconfiguration of the website. You may consider contacting the website administrators to report the error so they can investigate it. If you are managing the website, contact the support team of your hosting provider to examine the problem further with them.