Files
supabase/apps/docs/content/guides/functions/status-codes.mdx
Miranda Limonczenko 494c7460ed docs: restructure five lookup pages onto the reference template (#54484)
Part of DOCS-1619

## Problem

Five lookup pages predate the reference template from #54454. They're
missing descriptions, mix context into the lookup, or list every entry
in the right-hand table of contents.

## Solution

- Restructure the five pages onto the reference template, with facts
unchanged.
- Add or rewrite each description, and put titles in sentence case.
- Turn the Edge Functions limits lists into tables, and move the 9
status codes to H4s under three categories.

## Preview links

| Page | Live | Preview |
| --- | --- | --- |
| Analytics bucket limits |
[Live](https://supabase.com/docs/guides/storage/analytics/limits) |
[Preview](https://docs-git-docs-reference-rework-supabase.vercel.app/docs/guides/storage/analytics/limits)
|
| Vector bucket limits |
[Live](https://supabase.com/docs/guides/storage/vector/limits) |
[Preview](https://docs-git-docs-reference-rework-supabase.vercel.app/docs/guides/storage/vector/limits)
|
| Realtime limits |
[Live](https://supabase.com/docs/guides/realtime/limits) |
[Preview](https://docs-git-docs-reference-rework-supabase.vercel.app/docs/guides/realtime/limits)
|
| Edge Functions limits |
[Live](https://supabase.com/docs/guides/functions/limits) |
[Preview](https://docs-git-docs-reference-rework-supabase.vercel.app/docs/guides/functions/limits)
|
| Edge Functions status codes |
[Live](https://supabase.com/docs/guides/functions/status-codes) |
[Preview](https://docs-git-docs-reference-rework-supabase.vercel.app/docs/guides/functions/status-codes)
|

## Review category (docs PRs only)

<!--
If this PR changes docs and you're on the Supabase team, select one
category.
PRs from forks are always reviewed as Low, so you can skip this section.
-->

- [ ] Critical: needs a review as soon as possible
- [ ] Urgent: the feature ships soon, or it's blocking something else
- [ ] Moderate: good to have soon, not urgent
- [ ] Low: get to it when you can

## Review instructions

1. Open each preview next to its live page. The limits and codes match.
2. Open the status codes preview. **On this page** lists the three
categories, not each code.

## Checklist

Check all before review:

- [ ] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-12-04 14:45:07 -08:00

143 lines
5.8 KiB
Plaintext

---
id: 'functions-status-codes'
title: 'Edge Functions status codes'
description: 'Look up the HTTP status codes that Edge Functions return, from 2XX success and 3XX redirects to 401, 404, 405, 500, 503, 504, and 546 errors, with fixes.'
subtitle: 'Understand HTTP status codes returned by Edge Functions to properly debug issues and handle responses.'
---
Look up what an HTTP status code from an Edge Function means and, for an error, its cause and solution. Check this page when an invocation returns a status code you don't expect, such as when `supabase-js` throws a `FunctionsHttpError` with the message `Edge Function returned a non-2xx status code`.
## Status codes
The following sections group the status codes by whether the function succeeded, the request had an issue, or the function or platform had an issue.
### Success responses
These status codes mean your Edge Function ran and returned a response.
#### 2XX Success
Your Edge Function executed successfully and returned a valid response. This includes any status code in the 200-299 range that your function explicitly returns.
#### 3XX Redirect
Your Edge Function used the `Response.redirect()` API to redirect the client to a different URL. This is a normal response when implementing authentication flows or URL forwarding.
### Client errors
These errors indicate issues with the request itself, which typically require changing how the function is called.
#### 401 Unauthorized
**Cause:** The Edge Function has JWT verification enabled, but the request was made with an invalid or missing JWT token.
**Solution:** Check each of the following:
- Ensure you're passing a valid JWT token in the `Authorization` header
- Check that your token hasn't expired
- For webhooks or public endpoints, consider disabling JWT verification
For more on diagnosing 401 responses, see [Edge Function 401 error response](/kb/troubleshooting/edge-function-401-error-response).
#### 404 Not Found
**Cause:** The requested Edge Function doesn't exist or the URL path is incorrect.
**Solution:** Check each of the following:
- Verify the function name and project reference in your request URL
- Check that the function has been deployed successfully
For more on diagnosing 404 responses, see [Edge Function 404 error response](/kb/troubleshooting/edge-function-404-error-response).
#### 405 Method Not Allowed
**Cause:** You're using an unsupported HTTP method. Edge Functions only support: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, and `OPTIONS`.
**Solution:** Update your request to use a supported HTTP method.
### Server errors
These errors indicate issues with the function execution or underlying platform.
#### 500 Internal Server Error
**Cause:** Your Edge Function threw an uncaught exception (`WORKER_ERROR`).
**Common causes:** This error usually comes from one of the following:
- Unhandled JavaScript errors in your function code
- Missing error handling for async operations
- Invalid JSON parsing
**Solution:** Check your Edge Function logs to identify the specific error and add proper error handling to your code.
```tsx
// ✅ Good error handling
try {
const result = await someAsyncOperation()
return new Response(JSON.stringify(result))
} catch (error) {
console.error('Function error:', error)
return new Response('Internal error', { status: 500 })
}
```
You can see the output in the [Edge Function Logs](/docs/guides/functions/logging).
For more on diagnosing 500 responses, see [Edge Function 500 error response](/kb/troubleshooting/edge-function-500-error-response).
#### 503 Service Unavailable
**Cause:** Your Edge Function failed to start (`BOOT_ERROR`).
**Common causes:** This error usually comes from one of the following:
- Syntax errors preventing the function from loading
- Import errors or missing dependencies
- Invalid function configuration
**Solution:** Check your Edge Function logs and verify your function code can be executed locally with `supabase functions serve`.
For more on diagnosing 503 responses, see [Edge Function 503 response](/kb/troubleshooting/edge-function-503-response).
#### 504 Gateway Timeout
**Cause:** Your Edge Function didn't respond within the [request timeout limit](/docs/guides/functions/limits).
**Common causes:** This error usually comes from one of the following:
- Long-running database queries
- Slow external API calls
- Infinite loops or blocking operations
**Solution:** Try the following:
- Optimize slow operations
- Add timeout handling to external requests
- Consider breaking large operations into smaller chunks
For more on diagnosing 504 responses, see [Edge Function 504 error response](/kb/troubleshooting/edge-function-504-error-response).
#### 546 Resource Limit (Custom Error Code)
**Cause:** Your Edge Function execution was stopped due to exceeding resource limits (`WORKER_RESOURCE_LIMIT`, previously it was `WORKER_LIMIT`). Edge Function logs should provide which [resource limit](/docs/guides/functions/limits) was exceeded.
**Common causes:** This error usually comes from one of the following:
- Memory usage exceeded available limits
- CPU time exceeded execution quotas
- Too many concurrent operations
**Solution:** Check your Edge Function logs to see which resource limit was exceeded, then optimize your function accordingly.
For more on diagnosing 546 responses, see [Edge Function 546 error response](/kb/troubleshooting/edge-function-546-error-response).
## Related resources
To find the specific error behind a status code, see the following pages:
- [Edge Functions error codes](/docs/guides/functions/error-codes): look up the `sb-error-code` header that an error response can include.
- [Edge Functions limits](/docs/guides/functions/limits): the limits behind `504` and `546` responses.
- [Edge Functions logging](/docs/guides/functions/logging): find the error in your function's logs.