Bad Request

Official Substatus codes
The request is invalid

Specification of the HTTP status code 400

Status code 400 Bad Request indicates that the server cannot or will not process the request because of a client error (for example, incorrect request syntax, invalid framing of the request message, or misleading request routing).

Source / Quote by: The 400 Bad Request HTTP Status Code is specified by section 6.5.1 of RFC7231.

How to throw a 400 statuscode with PHP?

To throw the HTTP status code 400 on a web page, the PHP function http_response_code can be used. The syntax is as follows: http_response_code(400) (PHP 5 >= 5.4.0, PHP 7, PHP 8)

Test the 400 HTTP status code

In order to be able to display the HTTP status code (in this case 400 Bad Request) and other information on the client side, the development console must be opened with F12. Afterwards you have to navigate to the tab "Network". Now you can open the page, in the network tab you should see the web page (example index.php). This must be selected and then the Herder section must be selected. Here the user will see the following result:

Status code 400 Bad Request
URL: https://http-statuscode.com/errorCodeExample.php?code=400
Status: 400 Bad Request
Those: Network
IP address: XX.XX.XX.XX
Status code 400 Bad Request

How to create a custom error page for the 400 status code

Creating your own 400 Bad Request error page is relatively easy with the web server "Apache" as well as with the web server "NGINX".

Apache Webserver

The web server "Apache" is one of the most popular web servers on the Internet. To create an own 400 Bad Request error page in "Apache", the following change must be made in the following file.

File: .htaccess
ErrorDocument 400 /errors/400.html

NGINX Webserver

Similar to the web server "Apache", "NGINX" is also widely used on the Internet. To create your own 400 Bad Request error page in "NGINX", the following change must be made in the following file.

File: sites-enabled/default
error_page 400 /400.html;
location = /400.html {
    root /usr/share/nginx/html;

Browser compatibility of the 400 status code

Chrome no data
Edge no data
Firefox no data
Opera no data
Safari no data
Chrome Android no data
Firefox for Android no data
Opera Android no data
Safari on iOS no data
Internet no data
WebView Android no data

Constants in programming languages


Sub status codes of the 400 status code

Sub status codes are purely technical, and should never be sent to the user. For example, if status code 400.1 is thrown, it may be logged, but status code 400 will be sent to the user.:
400.1 Invalid Destination Header
HTTP IIS, Unofficial
400.2 Invalid Depth Header
HTTP IIS, Unofficial
400.3 Invalid If Header
HTTP ISS, Unofficial
400.4 Invalid Overwrite Header
HTTP ISS, Unofficial
400.5 Invalid Translate Header
HTTP ISS, Unofficial
400.6 Invalid Request Body
HTTP ISS, Unofficial
400.7 Invalid Content Length
400, Unofficial
400.8 Invalid Timeout
HTTP ISS, Unofficial
400.9 Invalid Lock Token
HTTP IIS, Unofficial
400.10 Invalid X-Forwarded-For (XFF) header
HTTP ISS, Unofficial
400.11 Invalid WebSocket request
HTTP IIS, Unofficial
400.601 Bad client request (ARR)
HTTP ISS, Unofficial
400.602 Invalid time format (ARR)
HTTP IIS, Unofficial
400.603 Parse range error (ARR)
HTTP IIS, Unofficial
400.604 Client gone (ARR)
HTTP IIS, Unofficial
400.605 Maximum number of forwards (ARR)
HTTP IIS, Unofficial
400.606 Asynchronous competition error (ARR)
HTTP IIS, Unofficial
Author: Tony Brüser
Author: Tony Brüser

Tony Brüser is an enthusiastic web developer with a penchant for HTTP status codes.