Home
/
Website Help
/
HTTP Status Codes
/
How to Fix HTTP Error 400 Bad Request

How to Fix HTTP Error 400 Bad Request

Sometimes, when trying to access a web page, your browser may return an error code “400 Bad Request,” and it is hard to tell what the actual problem is. The 4xx HTTP error codes are client-side errors, and the different codes indicate the reason for the failed request. Here you can see a detailed explanation of the various HTTP status codes.

“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 HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (for example, malformed request syntax, invalid request message framing, or deceptive request routing).

In other words, you are trying to access a website by sending a request to the website’s server. The server can’t recognize and process your request – thus, it returns the “400 Bad Request” code.

The “400 Bad Request” page may be displayed differently. Some browsers may not show the error code and instead display a blank page. Also, it is important to note that the page for this error may be customized on the website’s hosting server. Below, you can see an example of a standard “400 Bad Request NGINX” error page.

"Nginx 400 Bad Request" page

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.

How to fix the “400 Bad Request” Error?

1. 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”.

Example:

  • ⛔️ Incorrect URL – www.example-website-.com or www.example website.com
  • ✅ Correct URL: www.example-website.com/

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 cause the “HTTP 400 Bad Request” Error.

2. 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 a 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.domain.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.

3. 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:

Another way to examine if the origin of the error is your browser cache is to test accessing the site from your browser in 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.

4. 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.

Extensions menu in Chrome

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.

Disable extensions in Chrome

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

5. 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:

6. 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.

Example:

  • ⛔️ Incorrect Action – Uploading a video file of 150MB to a website where the maximum upload limit is 100MB.
  • Correct Action – Compressing the video file to 80MB and then uploading it to the website.

7. 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.

8. 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.

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,
  • a server-related error.

We will examine each type of error in detail and what are its most common causes.

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 a URL with a syntax error:

https://www.domain.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.

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 the 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 – when 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.

Share This Article