Skip to content

By the Octri team · Updated

500 Internal Server Error

Share

A 500 means something went wrong on the server that it didn’t expect and can’t describe more precisely. The client did nothing wrong, and the same request may work a moment later.

All HTTP status codes

Class
5xx server error
Defined in
RFC 9110, section 15.6.1
Retry
If the method is idempotent
Fix
On the server
Cacheable by default
No

When your API should return 500

A 500 is what your framework sends when an exception escapes, so you rarely return it on purpose. Make sure the body is still your normal JSON error with a request ID, and never a stack trace or a proxy’s HTML error page.

If you know the cause, use a more precise code. A dependency that’s down or a deploy in progress is a 503, a bad response from an upstream server is a 502, and a feature your API hasn’t built is a 501.

How public APIs declare 500 in their OpenAPI specs

Six of the eleven public specs we score declare a 500, as they were on 4 December 2026. Asana does on all but one of its 302 operations, and OpenAI and GitHub on about 120 each.

A declared 500 rarely changes what a client does, since it can’t fix the cause. What it adds is the error schema, which is how the request ID reaches a support ticket.

APIOperationsDeclare 500How errors are described
Asana302301Per status code
OpenAI406122Per status code
GitHub1,288117Per status code
Box29720Per status code, plus a default
Adyen Checkout2820Per status code
SendGrid Mail33Per status code
Stripe6120One default error response
Plaid3510One default error response
Twilio1970No error responses
Slack1740One default error response
Swagger Petstore190Per status code, plus a default

Counted per operation from each vendor’s public OpenAPI document on 4 December 2026.

Declare 500 in your OpenAPI spec

Declare 500 through a shared response with your standard error schema, and make the request ID a required field so every client can quote it.

yaml
paths:
  /invoices:
    get:
      operationId: listInvoices
      responses:
        "200":
          $ref: "#/components/responses/InvoiceList"
        "500":
          $ref: "#/components/responses/InternalError"

components:
  responses:
    InternalError:
      description: Something failed on our side. Quote the request ID to support.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
  schemas:
    Error:
      type: object
      required: [code, message, requestId]
      properties:
        code:
          type: string
        message:
          type: string
        requestId:
          type: string

What an Octri SDK does with a 500

An Octri SDK retries a 500 when the method is idempotent, which means GET, HEAD, PUT, DELETE and OPTIONS, up to 3 attempts with exponential backoff and jitter. It doesn’t retry a POST or a PATCH on a 500, because the first attempt may have done the work.

When the retries run out, the caller gets an SdkInternalServerError, the class every 5xx maps to in TypeScript, Python, Java, Kotlin, PHP and Ruby. It carries the request ID your API sent, so a bug report can name the exact request.

typescript
import { Acme, SdkInternalServerError } from "acme-sdk";

const acme = new Acme({ apiKey: process.env.ACME_API_KEY });

try {
  await acme.invoices.list();
} catch (err) {
  if (err instanceof SdkInternalServerError) {
    // Already retried 3 times. Quote the request ID to support.
    console.error(err.statusCode, err.requestId);
  }
  throw err;
}

More on retries and typed errors in SDK error handling.

See which 500s reached your users

Your server logs every 500 it sends. What they don’t show is which of those still failed for the caller after the SDK’s retries, and those are the ones that broke something for a user.

An Octri SDK with monitoring switched on reports each of those to Octri Monitoring with the status code, the operation and the request ID, so you can match it to your server log. Monitoring groups repeats into one issue, and it can alert you on a new issue or on one that comes back after you marked it resolved.

Monitoring is off in the SDK until the developer using it turns it on, so the count covers the users who did.

sql
level = 'error' AND statusCode >= 500
  ORDER BY timestamp DESC LIMIT 50

HTTP 500 questions

Should a 500 response include error details?

No, not internal ones. Stack traces and SQL errors help attackers more than developers. Send a short message and a request ID, and keep the details in your logs under that ID.

Is it safe to retry a POST after a 500?

Partly. Only when your API supports idempotency keys and the request sent one, so the server can tell a retry from a second order.

Do 500s count against an uptime SLA?

Often, yes. Many API SLAs measure availability as the share of requests that didn’t get a 5xx, so a 500 that should have been a 400 costs you in the uptime report.

Share