API returning 500

Also searched as: api 500

Updated 11 October 2026

Short answer

A 500 from an API means the request reached the server and its code crashed handling it. If it's your own API, your server logs have the exact exception and stack trace for that request; that's where the answer is. If it's a third-party API, check its status page, then whether your request is unusual (special characters, a very large payload, a new field) since that can trigger bugs on their side.

What's the problem

API calls return status 500 ("Internal Server Error"), sometimes for all requests, sometimes only for certain inputs.

Why it happens

  • A bug in the API's code, often from a recent deploy.
  • The API's database is down, slow or out of connections.
  • Missing configuration: an environment variable or secret not set in production.
  • Unexpected input the code doesn't handle, such as an empty field or an unusual character.
  • A dependency failing: another service the API calls.

How to fix it

  1. Note the exact request: URL, method, body, and time.
  2. If it's your API, find that request in your server logs and read the exception.
  3. Check what changed: deploys, config, or data, just before the 500s started.
  4. Check the database and other services the endpoint depends on.
  5. If it's a third-party API, check its status page and contact its support with the request details and any request ID in the response.
  6. Add error handling so bad input returns a clear 400 instead of a 500.

What Preventionlabs checks

One click runs the full report on your domain. For this problem it shows whether your site loads, how fast, and where its redirects go. With Cloudflare connected, it also shows which pages returned server errors (5xx) to visitors, and when; errors thrown by your Workers code; recent deploys and account changes, with their times. It doesn't call your API with your app's own requests or read your logs, so test the failing request directly as well.

Run your free report

Your first report is free, no card needed. Then A$50 a month, up to 10 domains. Read-only: it never changes anything.

Sources

  1. MDN Web Docs: 500 Internal Server ErrorreferenceThe HTTP 500 Internal Server Error server error response status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request.
  2. MDN Web Docs: 500 Internal Server ErrorreferenceServer administrators may proactively log occurrences of server error responses, like the 500 status code, with details about the initiating requests to improve the stability of a service in the future.
← All of API