HTTPS API requests to one of the virtual hosts are returning 400 Bad Request

We are making HTTPS API requests and getting 200 successful responses on most of the virtual hosts but we are 400 Bad Request with the following html page on one of the virtual hosts:

400 Bad Request

<head>
<title>Error</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>


<body>
<h1>An error occurred.</h1>
<p>Sorry, the page you are looking for is currently unavailable.<br/>
Please try again later.</p>
</body>


</html>
Solved Solved
0 3 417
1 ACCEPTED SOLUTION

After investigation figured out that the cause for getting 400 responses on the specific virtual host was that there were duplicate virtual hosts. That is the same host alias and port # were defined in "dev" and "test" environments.

Removing the duplicate host alias from one of the virtual hosts solved this problem.

There's also antipattern documented here about having multiple virtual hosts with the same host alias, possible impacts and best practices to avoid this issue.

View solution in original post

3 REPLIES 3

After investigation figured out that the cause for getting 400 responses on the specific virtual host was that there were duplicate virtual hosts. That is the same host alias and port # were defined in "dev" and "test" environments.

Removing the duplicate host alias from one of the virtual hosts solved this problem.

There's also antipattern documented here about having multiple virtual hosts with the same host alias, possible impacts and best practices to avoid this issue.

Not applicable

Returning 400 means that the request was malformed. In other words, the data stream sent by the client to the server didn't follow the rules. The client SHOULD NOT repeat the request without modifications. It means that the request itself has somehow incorrect or corrupted and the server couldn't understand it. The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method . Therefore, it prevents the website from being properly displayed. To fix a 400 Bad Request error, it is best to start diagnosing the issue from the client side itself. Complete the steps outlined in this section to help diagnose and correct the error.

  • Check for errors in the URL.
  • Clear Browser Cache and cookies.
  • Clear DNS Cache.
  • Check your File upload Size.
  • Deactivate Browser Extensions.
  • Contact the site owner to report the 404 error.

The 400 (Bad Request) status code indicates that the server cannot or will not process the request because the received syntax is invalid, nonsensical, or exceeds some limitation on what the server is willing to process. It means that the request itself has somehow incorrect or corrupted and the server couldn't understand it. The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method . Therefore, it prevents the website from being properly displayed. The main thing to understand is that the 400 Bad Request error is a client-side error. The cause of a 400 error can be a wrongly written URL or a URL that contains unrecognizable characters. Another cause of the error might be an invalid or expired cookie. Also, if you try to upload a file that's too large. If the server is programmed with a file size limit, then you might encounter a 400 error.