Web Development

HTTP error 400: how to fix it?

By David, on December 1, 2022, updated on June 1, 2023 - 7 min read

A status code indicates the status of the communication between the web server and our website. When there is a problem, the server returns an error notification that is displayed on our browser. The error 400 bad request for example announces that there is a problem with the request of our site.

This can be caused by a number of things including:

  • an incorrect URL ;
  • corrupted browser cache or cookies;
  • uploading files that are too large;
  • etc.

In this guide, we’ll explain each cause of the 400 bad request error and tell you how to fix the problem. Are you ready? Let’s go !

What does 400 bad request error mean?

HTTP error 400, error 400, error 400 bad request are all names for the same problem. The server returns this error code when it considers that the error does not match any of the other status code types.

The issue is indeed related to the client request (our website). The error occurred long before the server started processing the client request. In most cases, the error message does not provide any information about the location of the communication trouble.

So we have to determine the source of the trouble by ourselves. However, if the web server has specific systems like IIS 7.0, IIS 7.5, IIS 8.0, we’ll have access to more details.

Our browser will then show:

  • 400,1 : Invalid Destination Header;
  • 400.2: Depth Header invalid;
  • 400.3: If Header not valid;
  • 400.4: Overwrite Header not valid;
  • 400.5: Invalid Translate Header;
  • 400.6: Invalid Request Body;
  • 400.7: Invalid Content-Länge;
  • 400.8: Invalid Timeout;
  • 400.9: Invalid Lock Token.

Note that this error code is not specific to web browsers. Other clients such as email clients also receive this message when they communicate with a web server.

Also read : How to fix Tachiyomi HTTP error 503?

Error 400: what causes it?

The 400 error code appears for different reasons.

Error in the syntax of the URL

A badly typed URL or a bad syntax can cause a 400 bad request error. A URL with illegal characters like ”{” can also produce it.

Corrupted cookies and browser cache

A 400 error code can appear even when the URL has no irregularities. Cache files or cookies may be corrupted.

For example, if we try to access our WordPress administration a little after our last login, a 400 error may occur. This is because the cookie that handles our authentication information is corrupted.

Our authentication as a valid user, administrator at that, becomes impossible. The connection is denied and the server returns a 400 bad request error.

Downloading large documents

When we try to download a large document from a website, a 400 bad request error can occur. This situation is this time related to the file size limit of the server.

This factor varies depending on the configuration that has been made by the administrator.

DNS lookup cache trouble

Domain names are aliases for IP addresses. An IP address can be thought of as a phone number that is always used to call the same server.

When we first connect to a website, a process takes place. It is called “name resolution“. During this process, a certain correspondence is established between the IP address of the server and the domain name.

Repeating this process every time we connect to the same site would not be practical. To avoid this, the data is stored in the local DNS cache on our computer.

Sometimes the locally stored DNS data is not in sync with the information stored online. At this moment, a 400 bad request error occurs.

Generic server error

When this kind of error occurs, it is beyond our control. The only people who can solve this trouble are those who own the website.

The status code 400 in this case indicates a general failure with the server or unspecified temporary failures.

The only thing you need to do as a visitor to the website is to refresh the page from time to time. This will be displayed if the owners solve the problem.

The length of the HTTP header

A 400 bad request error can come from the size of the HTTP header. If the header is too long it can indeed create this type of error.

Note that normally, there is no limit to the length of the headers. However, the server has the possibility to define a limit.

Remember that a header consists of different fields in which requests and responses are defined. For data to be exchanged, the server and the browser must agree on the parameters of the communication.

If this is not the case, the client and server cannot exchange their information. A 400 bad request error is then displayed.

What solutions are there to correct the 400 bad request error?

There are several solutions to overcome the 400 bad request error. In most of these solutions, you’ll notice with us, the step of emptying the data stored in the cache of the computer.

We might think that the ultimate solution to connection errors would be for the computer to stop caching data. This is true. However, without caching, the user experience would become uncomfortable.

Web activity is a constant trade-off between user experience and optimization. To improve the user experience, pages load as fast as possible involving caching techniques. In doing so, sites can suffer from an error like the 400 bad request without warning.

Check the URL

In a situation where our browser displays the 400 error code, the first reaction is to check our URL. This is the most common error reason.

Let’s face it, it’s easy to insert errors such as an unwanted character into a handwritten URL. So let’s start checking the spelling of the entered domain name and the target page. Let’s also check for the presence of slashes between the target page and the domain name.

The special characters in the URL should be legal and properly encoded. Make sure of this.

In the case of a long URL, you can use an online URL decoder/encoder.

This will make it much easier for you to verify the URL. In addition, you’ll avoid making mistakes again.

Once you are satisfied that the URL syntax is correct, go back to the browser you used when you first logged in. Try again to access the page corresponding to the URL.

If the web page appears then the trouble is solved. But if the 400 bad request notice is still displayed, let’s move on to the next solution.

Delete the content cached by the browser

A browser’s cache stores any files that allow a website to function properly as:

  • HTML codes;
  • CSS codes;
  • JavaScript codes;
  • text documents;
  • Multimedia content;
  • XML.

To resolve connection errors, especially error 400, the cache must be cleared of all files. The procedure for cleaning the cache varies depending on the browser you use.

With chrome, for example, we need to click on the icon of personalization and control of Google chrome. This is the three dots in the upper right corner of the screen.

Then we must click on “Settings”. On the settings page, click on ”PRIVACY AND SECURITY”.

Then click on ”DELETE Browsing Data”.

In the window that appears, make sure that the option ”PICTURES AND FILES IN CACHE” is checked. Press ”DELETE DATA” to empty the cache.

You have the choice to delete all files or those of a specific period. We recommend that you delete everything. This way you can be sure that there are no more corrupted files in the cache.

To do this, select ”ALL DATA” at the option of the period.

capture décran 2022 11 25 à 10.46.44

Delete cookies

If emptying the cache does not work, let’s move to the deletion of cookies. In general, websites use several cookies. A single corrupted or expired cookie can trigger login errors.

To solve the issue, we’ll follow the same process as when deleting cached files.

We must click on ”DELETE DATA” to delete all cookies. Again, select “ALL DATA” for the period.

Send your request to the server again to check if the error code “400 bad request” is still displayed.

Reduce the volume of the file

When we encounter connection errors while trying to upload a large file to a website, several solutions exist. As site administrators, we can increase the file volume limit of our server.

This can be done from the Cpanel of our web hosting. However, as simple users, we are obliged to comply with the limit imposed by the server.

We have a lot of online tools that help reduce the size of a file without damaging its quality. To make sure that the error comes from the file, we need to perform a test.

To do this, we’ll upload a smaller file than the previous one. If it downloads, it means that the first file is too large. We must then reduce it.

Delete the content stored in the DNS cache

In order to solve the problem of connection errors, we need to clear the DNS cache. The deletion procedure therefore varies depending on the OS installed.

On Windows, it takes place in several steps. The first step is to empty the browser’s cache. This is a condition for successfully clearing the DNS cache.

For the second step, we need to open the command prompt. To do this, type the keyboard shortcut ”Windows + R” to access the search window. Now we enter the term cmd and validate. The command prompt opens immediately. This is a window with a black background.


The next step is to type a command in the command prompt. So let’s type


The DNS cache will be deleted at the same time.

Finally, let’s turn off the computer. Let’s leave it like that for about two minutes. Then turn it back on.

Reduce the length of the HTTP header

Here, our request is not successful because the browser’s header exceeds the server’s limit. Before solving the issue, let’s do a test to see if our default browser is the problem.

To do this, let’s choose another browser and try to connect to the web page. If the request succeeds, we’ll deduce that the source of the problem is the default browser.

We’ll now delete all cookies if this has not been done before. By doing this, we reduce the size of the client request header.

This is because cookies are transferred in the header to help the server learn information about our previous visits. Too many entries in the browser request could increase the length of the header. The limit set by the server may therefore be exceeded.

If our connection request still results in a 400 error code, we will reinstall the browser. Otherwise, we’ll revert to the factory settings.

The reset process varies on each browser.

After the reset, our passwords, history, etc. remain. The browser still returns to the factory state. To see the changes, you need to close and restart it.

To fix this problem as a webmaster, simply increase the server header limit. As with the file size, you need to go to our hosting to do this.

Note, however, that too large a header limit can increase the risk of spoiled requests.

Disable extensions

Extensions installed on a browser can cause connection errors. Usually we don’t think about this. But if none of the other solutions work, we can disable these extensions. This is a temporary deactivation. This way we can see if it makes a difference or not. So disable the extensions and send our request to the web server again.