Skip to content
FR
  1. LuzineDebug
  2. Tools
  3. HTTP status codes

HTTP status codes: meaning, causes and fixes

All the common HTTP codes (401, 403, 404, 419, 429, 500, 502…): meaning, causes and what to do. Everything happens in your browser.

200 OK

The request succeeded.

Common causes: Normal response.

What to do: Nothing to fix. If the content is empty or unexpected, check the response body and the Content-Type header.

201 Created

Resource created.

Common causes: Normal response to a POST that creates an item.

What to do: The new resource URL is often in the Location header.

204 No Content

Success, no content.

Common causes: Common after a DELETE or an OPTIONS request (CORS preflight).

What to do: Do not call response.json() on a 204: there is nothing to read.

301 Moved Permanently

The resource moved permanently.

Common causes: Domain change, switch to HTTPS, trailing / added or removed.

What to do: Update your links. Beware: a POST redirected with 301 may turn into a GET; use 308 to keep the method.

302 Found

Temporary redirect.

Common causes: Login page, redirect after a form.

What to do: If an API answers 302 to /login, your session or token is not being sent.

304 Not Modified

The browser cache is up to date.

Common causes: Conditional request (If-None-Match, If-Modified-Since).

What to do: Normal. If you do not see your changes, clear the cache or version your files (app.js?v=2).

307 Temporary Redirect

Temporary redirect that keeps the method.

Common causes: Browser-internal HSTS, maintenance, load balancing.

What to do: Follow the Location header with the same method and body.

308 Permanent Redirect

Permanent redirect that keeps the method.

Common causes: An API endpoint moved.

What to do: Update the URL you call.

400 Bad Request

The server cannot understand the request.

Common causes: Malformed JSON, missing or wrongly typed parameter, missing Content-Type header, cookie too large.

What to do: Read the response body (it often names the faulty field) and validate your JSON.

403 Forbidden

You are identified but not allowed.

Common causes: Insufficient rights, firewall or WAF, blocked IP, file permissions on the server, CSRF token rejected.

What to do: Check the account roles, the firewall rules and, on the server, folder permissions (chmod 755 for folders, 644 for files).

404 Not Found

The resource does not exist at this address.

Common causes: Typo in the URL, undeclared route, stale route cache, missing URL rewriting, wrong method served by another route.

What to do: Compare the exact URL called with the route list (php artisan route:list, flask routes…), then clear the route cache.

405 Method Not Allowed

The HTTP method is not accepted here.

Common causes: Calling a POST route with GET, form without @method('PUT'), redirect turning a POST into a GET.

What to do: Use the method the route expects; the Allow header lists the possible methods.

408 Request Timeout

The client took too long to send the request.

Common causes: Slow connection, large upload, proxy.

What to do: Retry, reduce the upload size or raise the server timeout.

410 Gone

The resource was permanently removed.

Common causes: Content removed, old API version shut down.

What to do: Remove links to this address or move to the new version.

413 Content Too Large

The request body is too large.

Common causes: File over client_max_body_size (Nginx), upload_max_filesize / post_max_size (PHP) or the API limit.

What to do: Raise the web server and language limits, or compress / split the upload.

415 Unsupported Media Type

Body format not accepted.

Common causes: Missing or wrong Content-Type header (text/plain instead of application/json).

What to do: Send Content-Type: application/json with a JSON body (or multipart/form-data for a file).

422 Unprocessable Content

Request understood but the data is invalid.

Common causes: Validation failed (required field, email format, length).

What to do: Read the returned error list (often errors in the JSON) and fix the fields.

431 Request Header Fields Too Large

Headers too large.

Common causes: Cookies piled up on localhost, huge token in a header.

What to do: Delete the domain cookies and slim down the headers.

451 Unavailable For Legal Reasons

Content blocked for legal reasons.

Common causes: Geo-restriction, court order.

What to do: Nothing to fix in code.

500 Internal Server Error

The server crashed while handling the request.

Common causes: Unhandled exception, syntax error, unreachable database, missing .env file, cache folder permissions.

What to do: Read the server logs (storage/logs/laravel.log, the Nginx/Apache error.log, the app output): the real error is there.

501 Not Implemented

Feature not supported by the server.

Common causes: HTTP method unknown to the server.

What to do: Check the method used and the API version.

502 Bad Gateway

The proxy got an invalid response from the app.

Common causes: App (PHP-FPM, Node, Gunicorn) stopped or crashed, wrong port or socket in the Nginx config, container not started.

What to do: Check that the app is running and listening on the port or socket the proxy points to, then read its logs.

503 Service Unavailable

Service temporarily unavailable.

Common causes: Maintenance mode (php artisan down), overloaded server, saturated third-party service.

What to do: Wait and retry (Retry-After header); leave maintenance mode with php artisan up.

504 Gateway Timeout

The proxy waited too long for the app.

Common causes: Slow request (database, external call, AI), proxy_read_timeout too short.

What to do: Speed up the work or move it to a background job; raise the proxy timeout if justified.

520 Web Server Returned an Unknown Error

Cloudflare code: empty or invalid response from the origin.

Common causes: Origin server crashed, headers too large, connection reset.

What to do: Test the origin server directly and read its logs.

522 Connection Timed Out

Cloudflare code: the origin server does not answer.

Common causes: Server down, firewall blocking Cloudflare IPs, wrong IP in DNS.

What to do: Check that the server is reachable and that Cloudflare IPs are allowed.

Read an HTTP code in 5 seconds

  • 2xx: success. If something is off, it is in the content, not the code.
  • 3xx: redirect. Follow the Location header.
  • 4xx: the request is at fault (URL, credentials, data). Fix it on the client side.
  • 5xx: the server is at fault. The answer is in its logs.

Frequently asked questions

What is the difference between 401 and 403?

401: the server does not know who you are (credentials missing or invalid). 403: it knows who you are, but you are not allowed to access the resource.

What is the difference between 502 and 504?

502: the proxy (Nginx, Cloudflare) got an invalid response or none from the app. 504: it waited too long. In both cases, look at the app logs first.

Does a CORS error have an HTTP status code?

No: the response can be a perfectly normal 200; the browser refuses to hand it to your script because the Access-Control-Allow-Origin header is missing.

Errors this tool helps solve

Access to fetch at 'https://api.example.com/users' from origin 'http://localhost:5173' has…

Fix "blocked by CORS policy: No 'Access-Control-Allow-Origin' header"

The browser blocks the response because the API server did not allow your page’s origin. The fix is on the server: send the Access…

JavaScript & Node.js Intermediate 20 min
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

Fix "Unexpected token '<', "<!DOCTYPE "... is not valid JSON"

Your code calls response.json() or JSON.parse(), but the server returned an HTML page (starting with <!DOCTYPE) instead of JSON. I…

JavaScript & Node.js Beginner 10 min
419 | Page Expired

Fix "419 Page Expired" in Laravel (CSRF token mismatch)

Laravel rejected a POST, PUT, PATCH or DELETE request because the CSRF token is missing or does not match the one stored in the se…

PHP & Laravel Beginner 10 min
RateLimitError: Error code: 429 - Rate limit reached for requests (rate_limit_exceeded)

Fix error 429 "Rate limit reached" on OpenAI, Claude and Gemini APIs

The provider rejects the request because you are over a rate limit: requests per minute (RPM) or tokens per minute (TPM). Wait for…

AI & LLMs Intermediate 20 min
openai.AuthenticationError: Error code: 401 - Incorrect API key provided: sk-proj-****abcd

Fix error 401 "Incorrect API key provided" / "invalid x-api-key"

The API does not recognize the key it received: it is missing, mistyped, revoked or sent in the wrong header. Check that the envir…

AI & LLMs Beginner 10 min
Error: could not connect to ollama app, is it running?

Fix "could not connect to ollama" and connection refused on port 11434

The client (the ollama command, your script or your app) cannot reach the Ollama server on 127.0.0.1:11434. Start the server (Olla…

AI & LLMs Beginner 10 min
OSError: You are trying to access a gated repo. Make sure to have access to it at https://…

Fix "You are trying to access a gated repo" (401) on Hugging Face

The model is gated: you must accept its license on its Hugging Face page, then authenticate with a token. Request access on the mo…

AI & LLMs Beginner 10 min
2026/11/27 09:14:02 [error] 31#31: *7 connect() failed (111: Connection refused) while con…

Fix "connect() failed (111: Connection refused) while connecting to upstream" (Nginx 502)

Nginx returns 502 Bad Gateway because nothing listens at its upstream address: PHP-FPM, Node or Gunicorn is stopped, listens on an…

Docker & DevOps Intermediate 15 min

Other tools