Skip to content
CheckcraftDownload
Practical workflow

API error 500: server problem or bad request

A 500 means the server crashed while handling the request. The fix belongs on the server, but the crash is often triggered by specific data in the request, and you can find it from the outside.

Checkcraft ·

Get help with your first test →

What a 500 actually means

The server accepted the request and failed to handle it because of an internal error, usually an unhandled exception. A correct server answers invalid data with 400 or 422 and an explanation. If you get a 500 instead, it is a server bug even when your request triggered it.

How to find what in the request breaks the server

Repeat the request and read the response body: it may contain an error text or a traceId. Then simplify the request: drop optional fields, replace values with known-good ones, try empty strings, null, very long values and special characters. When the 500 disappears, the last change is the cause. With the traceId or request time, a developer can find the exception in the logs.

curl -i -X POST https://api.example.com/orders -H "Content-Type: application/json" -d "@order.json"

How 500 differs from 502, 503 and 504

502 Bad Gateway and 504 Gateway Timeout come from a proxy or load balancer: the service behind it did not answer or answered with an error. 503 Service Unavailable means the service is overloaded or under maintenance. In these cases the request is usually not the problem; the service availability is.

Request failed with status code 500

This is the axios library message: it throws on any response outside the 2xx range. The text itself says nothing about the cause; look at error.response: the status, headers and body the server sent.

try {
  await axios.post('/api/orders', order);
} catch (error) {
  // Request failed with status code 500: see what the server sent
  console.log(error.response?.status, error.response?.headers, error.response?.data);
}

How not to miss a 500 in automated checks

Check the status code with its own rule and give every required field a check of its own. The report then says at once that a 500 arrived and on which request, and in Checkcraft the log records found by traceId sit next to it.

Next step

Repeat this on your own API

Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.

Download FreeDownload and first run

No sign-up or email needed, the archive is ready in a couple of minutes. See the edition limits.

References

MDN: HTTP status codes

Start with the linked example and compare its result with your own test requirement.

Ask a person

Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

No account required. We will reply by email. This is a support request, not a newsletter subscription.