Error 400

The400 error, also known as “HTTP 400 error” or “400 Bad Request error” is a status code in the HTTP protocol that means that the request sent by the user to the server is erroneous or corrupted and the server is unable to process it

While trying to access a website, you may be presented with a blank page with only the words “400 Bad Request”

  • What does this mean?
  • Why do you see this message?
  • And how do I fix a 400 Bad Request error?

These are just a few of the questions we’ll cover in this guide

Follow along!

Chapter 1: What is the 400 error?

Here I explain

  • What is meant by error 400;
  • How it manifests itself;
  • The consequences it can cause.

1.1. how to understand the 400 status code?

All activities on the Internet are the result of a permanent communication between clients (browsers) and servers

The client sends requests to the server. The server processes them and sends the answers back to the client who displays them.

This communication is carried out by means of a set of code belonging to the HTTP (hyper text transfer protocol).

Source : SchoolMoov

The answers sent by the server are grouped into four classes of codes

  • The code class 1xx (100, 101, 102…) These codes inform the browser that operations are still being processed;
  • The 2xx code class (200, 201, 202…): They are sent when the request submitted by the browser is completed are sent when the request submitted by the browser is understood and processed;
  • The class of code in the form 3xx (300, 301, 302) these are the codes that redirect. These responses are sent when an old URL has been replaced by a new one ;
  • The code classes in the form 4xx (400, 401, 402…) and 5xx (500, 501, 502…): These codes these codes appear when a problem occurs during the processing of browser requests. A distinction is made between server-side errors and client-side (browser) errors. Server-side errors belong to the 5xx code class while client-side error messages are grouped in the 4xx code category.

You will not see the concrete manifestations of codes 100 and 200 between clients and servers in your interactions because you will usually be directed to the requested resource

Only error messages and, to some extent, messages that indicate a redirect are visible to you.

In reality, the 4xx and 5xx code classes are displayed if there is a problem in the processing of operations between the server and the client. This is probably why they are called “error codes”

Moreover, let us recall that from the display of an error code, it is easy to identify the causes of an HTTP error

Class 4xx codes assume that the error must be looked for on the client side, whereas class 4xx codes indicate that the error must be looked for on the server side

Thus, when the browser displays the error 400, it means that the causes of this error are to be sought at the level of the computer making the request

Erreur-400-2

However, this is not enough, because we need to understand what the code means in order to solve the problem.

As I have already explained, when your browser displays the 400 error message, it means that the request you are trying to make from the browser is incorrect, corrupted or that the server cannot understand it.

The 400 error indicates that the request made is incorrect. This is what justifies the expression “Bad request” associated with it.

It must be said that the 400 error is not as precise as the other types of errors in its category

In fact, unlike the other codes in the 400 category, it is difficult to tell automatically what is wrong when a 400 error is displayed.

Whereas 401 or 404 codes are returned by the server and indicate respectively that :

  • The authentication information sent is not valid
  • The requested resource does not exist.

The only information you have at the 400 error level is that the request made cannot be processed or is faulty

You will have to do your own checks to determine the possible causes of this error

However, note that when your server uses an IIS (Internet Information System) 7 or higher, you get more detailed information

With such a system, you may see the following details about the 400 error

Source ionos

Now that you have a clear idea of the 400 error, find out how it occurs before we look at its causes

1.2. what does a 400 error look like?

Here’s how Error 400 is displayed in browsers like

  • Chrome

  • Firefox :
  • Microsoft edge
  • Internet Explorer

1.3. The various causes of 400 errors

As I mentioned earlier, the 400 error is an error that occurs on the client side

Therefore, the causes are to be identified at the level of your browser. In concrete terms, this can be due to several situations

Among these you have

1.3.1. The presence of a typing error in the URL address

The URL of a site is the address of this site

A modification or a wrong entry of this URL constitutes an error and is sufficient for you to see the error message 400 appear on your screen

Similarly, the use of a URL containing certain special characters or characters that the server cannot process can cause 400 errors

1.3.2. The cache or corrupted cookies

The web cache is a form of temporary memory that can be found in both browsers and servers

It allows to store in memory some of the visitor’s data in order to make his next visits on the site even faster

As for cookies, they are set up to record information about how you use a site

Source Cpdos

Whether it is the cache or the cookies, they are stored in your browser

They allow you to easily and quickly access a site you have already visited

However, they can cause a 400 error when they are:

  • Corrupted;
  • Expired;
  • Or when they encounter inconsistencies.

1.3.3. The non-synchronization of DNS data

When you want to access a site for the first time, several processes take place

Among these you have the step where the domain name has to contact the server by finding its specific IP address

As soon as this contact has taken place, the information is kept in a file on your computer

Source KeyCDN

This file is called DNS cache. It facilitates faster access to the site later on. Because it allows you to skip the step of searching for the IP address.

It can cause a 400 error when the DNS cache file can no longer synchronize with the site data

1.3.4. Downloading a file that is too large

Apart from URLs that may be mistyped, or saved files that may be corrupted, 400 errors can also result from trying to download files that are too large

In fact, depending on the server and its configuration, you may encounter problems when trying to download files that are a certain size.

Technically, if the download takes a long time, it means that your request has not been properly processed. The server may send a 400 error message to notify you of this

1.3.5. Problems with the server

For other reasons not originating from the client, you may also encounter a 400 error

This would indicate that the server is experiencing unspecified general problems and that it is impossible for you to access it.

1.3.6. Incorrect sample requests

Some servers may be configured to process requests only when they are sure that there is nothing malicious in the request

In these cases, when the request is made, they must check that it includes certain elements

Source Slideplayer

When this is not the case, a 400 error may be displayed

1.3.7. A URL that is too long

The communication between the client and the server is essentially established in the HTTP header. Some servers are configured to take into account only a limited number of characters in the headers

So when the size of the URL is too long, elements may be missing during processing and the server will consider the request as wrong, hence the return of a 400 error message

From the causes listed above, it is quite legitimate to wonder whether the appearance of a 400 error does not have consequences.

1.4. The possible consequences of a 400 error

The main consequence of a 400 error is that it prevents you from accessing a resource on the Internet

If you are an Internet user and this error comes from your browser, you will not be able to access the site you wish to visit

However, if you are a webmaster and the presence of the 400 error depends on a situation that escapes the Internet users, it will certainly have an impact on your site

Indeed, at this moment, the 400 error affects the user experience, but can also act on the SEO.

In the long term, it could affect the performance of your site.

It may also prevent search engines from crawling your site

Alternatively, you can check your site for errors by visiting the search console.

1.5. How to identify a 400 error on a website?

To check if there are 400 or other errors on your site, from the search consoleyou must

  • Go to your Google Search Console account;
  • Click on “coverage” to see the elements of your site that display errors or could not be indexed

You will find

  • Pages with errors
  • Valid pages
  • Pages that could not be crawled for any reason;
  • As well as excluded pages.

You can also use the URL inspection tool to check the status of any URL belonging to your domain.

Now that you are aware of the implications that the 400 error can cause, I will provide you with some solutions to overcome it

Chapter 2: How to Fix Error 400

In this chapter, I will offer you various solutions to overcome the 400 error

These solutions can be divided into two categories

  • Simple solutions that any Internet user can perform in their browser
  • Solutions that require a minimum of computer knowledge. These solutions are aimed more at webmasters.

2.1. The simple solutions

Faced with a 400 error that occurs when you try to visit a site, here are some solutions that you can try:

2.1.1. Check the URL

One of the most common causes of 400 errors is mistyping the URLs you want to access

That’s why the first solution I suggest is to check your URL.

This recommendation consists of taking a closer look at the URL you have just entered in order to identify if you have made a mistake in the entry

If so, you simply need to retype it

But when this solution does not work, you can turn to other types of solutions

2.1.2. Empty the cache or cookies

As you will have understood, the cache or cookies contain files (HTML, JavaScript, CSS media compressed file, json, etc.) of a site saved in your browser may have errors or be corrupted. What

When this happens, the solution to consider is to delete these files by clearing the cache in the browser you are using.

To clear your cache, you can do the following:

2.1.2.1. If you are using, chrome
  • Go to “Settings” and then to “Privacy and Security” choose “Clear Browsing Data”:
  • In the window that appears, check the boxes
    • ” ‘Download history’
    • in the window that appears, check the boxes: “‘Download history”; “‘Cached images and files”
    • in the window that appears, check the boxes: “‘Download history”; “Cached images and files”; “Cookies and other site data” and then click on the “Clear data” button
2.1.2.2. If you are using Firefox
  • To clear the cache on a Firefox browser, simply click on “Options” and then “Privacy and Security”
  • Then scroll down the page and click on the “Clear Data” button
  • A pop-up menu will open, click on the “Site caches and data” and “Cached web content” boxes
  • Then click the “Clear” button.
2.1.2.3. If you use Microsoft edge
  • You can clear your cache or cookies by going to “Settings”:
  • Select the “Privacy, Search and Services” tab
  • Scroll down the page to the “Clear Browsing Data” section
  • Click on “Choose items to delete”;
  • Check in the menu that appears on the screen the elements of the site that you wish to erase, in particular the cookies and the cache.

2.1.3. Reduce the size of the files you want to download on the site

When it is the large size of the file you want to download that is causing the problem, you will have no choice but to reduce it.

This will depend on the type of file you have (is it an image? A video? A document? Or an audio file?)

Whatever the type of file, keep in mind that you will find various easy-to-use tools and utilities on the internet. They will allow you to reduce the size of your files

2.1.4 Clearing the DNS cache

As I just explained, the locally stored DNS cache file can also be the cause of the 400 errors

If this is the case, it is up to you to do the same thing with the cookies and the cache of the sites, i.e. delete them

But unlike the previous files, deleting the DNS cache is done in a different way

The deletion can be done from your operating system or on the browser

I will discuss how this deletion is done both on the Windows operating system and on browsers such as

  • Google Chrome ;
  • And Firefox .
2.1.4.1. Clearing the DNS cache on the operating system level

Here is how to clear your DNS cache when using

Windows

Clearing the cache on an operating system like Windows is done as follows:

  • Enter “Command Prompt” in the Windows search box
  • Click on the “Open” button in the results offered by your computer
Ouverture de l invte de commande

You will recognize the command prompt by an all-black window that will appear on the screen.

  • Then enter the following command line faithfully: ” ipconfig/flushdns”.
IIinviite de commande

You should then receive a confirmation message telling you that the cache has been deleted.

On the other hand, if you are using older versions of Windows, although the commands remain the same, note that the process for accessing the command prompt is a little different

On Windows 8, for example, you must

  • Go to the Application screen;
  • Search for Windows Systems ;
  • Search and click on Command Prompt

On Windows 7 and Windows XP on the other hand, you need to

  • Press the “Start” button;
  • Choose “All Programs”
  • Click on “Accessories”;
  • Choose the command prompt.
Mac

To clear your Mac’s DNS cache, you must:

  • Open your command line terminal
  • Enter the command: sudo killall -HUP mDNSResponder if you are using version 10 or higher;
  • Enter your password and wait for the deletion

Source Kinsta

Linux

When you use a Linux machine to proceed to the deletion of your DNS cache, the process you adopt depends on your terminal

If you are using UNBUNTU, you need to access your command line to do this

  • Click on activities ;
  • Enter the word terminal in the search bar that appears;
  • Run the program;
  • Run the command sudo systemd-resolve –flushcaches
  • The terminal will ask you for your password. Enter it then wait for the confirmation of the DNS cache deletion and finish the operation

Note that if you are using a Linux terminal other than UBUNTU, the command to enter is: sudo/,etc./init. d/dns-clean start

2.1.4.2. Clearing the DNS cache in your browser

If you are using a browser like Firefox, you can disable the browser’s DNS cache by following this process

  • Type about:config in the address bar;
  • Type in the search bar: network ;
  • Choose from the list network.dnsCacheExpiration ;
  • Click on modify (the button with the pen logo on the right of your screen) and change the numerical value to 0.

To do this with Google, you just have to

  • Enter in the address bar the command: chrome://net-internals/#dns
  • Then click on the “Clean host cache” button;

2.1.5. Disable recent extensions, modules and plugins

When the previous solutions don’t work, I recommend you to take a look at your extensions

You may have downloaded extensions that have features that affect the way cookies work

If you are using extensions, disable them while you check if the 400 error is still present

This firmware allows you to add new features to your computer

But it may completely change the way it works, causing an error 400

2.1.6. Disconnect and reconnect

If you are using an application that has an authentication method, you may want to try the logout and log back in maneuver

This is because the application may be having problems with your previous session.

If the server thinks your session is invalid or compromised, it will give you a 400 bad request error message.

2.2. Solutions for webmasters

Here are some more technical solutions that webmasters could try if it turns out that the 400 error is not from a cause they are dependent on.

2.1. Remove recent updates

If it’s after an update that your visitors are complaining about a 400 error, one possible solution is to revert to the version you were previously using that seems to be working fine

2.2.1. Check the HTTP headers

If everything seems to say that the client browser is not responsible for the appearance of the 400 errors that you encounter, it is possible that the 400 error is the result of a missing or invalid HTTP header that your server is expecting

To be sure, perform a check of these headers to determine if they are invalid. To do this, you can use an online checker like web sniffer

2.2.2. Checking the Activity Log

Most applications keep some form of logs where you will find the history of the tasks they perform.

This information provides a range of information related to the operation and health of the application

So, if you are using an account manager for example, you can consult your activity log to identify when the problem occurred and then try to solve it

2.2.3. Debugging code and scripts

If all these solutions still do not solve the problem you are facing, it is likely that the problem is the result of the execution of a custom code that you have implemented

You can therefore try to diagnose the problem by running your code step by step in a debugging tool. This will allow you to identify when you have made an error.

Chapter 3: Frequently Asked Questions

3.what is the 400 error code?

When you send a request from your web browser, the server has to process it and send you a response. If this response is a 400 Bad Request error message, this would mean that a problem has occurred during the processing of the response and the server is unable to respond favorably to your request

3.2. What causes a 400 error?

A 400 error can occur when

  • There is a typo in the URL address
  • The cache and cookies are corrupted or expired
  • The data stored in the DNS cache is not in sync with the site
  • You are trying to download a file that is too large
  • You enter a URL that is too long

3.2. how to solve the 400 Bad Request error ?

  • If you are a simple Internet user
    • Check the URL you are trying to access for typos
    • Clear your browser’s cache and cookies
    • If the download is too large, reduce the size of the file to be downloaded
    • Clear your browser’s DNS cache
    • Deactivate the extensions, plugins and modules that you have recently installed;
    • Log out of your session and then log back in
  • If you are a webmaster
    • Remove recent updates and restore a previous working version
    • Check the HTTP headers
    • Check your activity log
    • Debug code and scripts.

In summary

Error 400 disrupts your online experience by preventing you from accessing a website

It is essentially the result of the client computer submitting a bad request to a server

In this article, I’ve discussed several solutions you can use to fix this situation.

If you know of any others, please feel free to share them with us in the comments.

Thanks and see you soon!

Leave a comment