# Troubleshooting
Source: https://sovaria.in/docs/troubleshooting

Find the fix for an error: how to read error responses, the most common status codes, and a guide per area — auth, database, storage, functions, realtime and your organization.

- [Authentication](https://sovaria.in/docs/troubleshooting-auth): Sign-in failures, emails, redirects, PKCE, rate limits, MFA, sign-outs.
- [Database](https://sovaria.in/docs/troubleshooting-database): Policy refusals, empty results, timeouts, connections, migrations.
- [Storage](https://sovaria.in/docs/troubleshooting-storage): Upload refusals, denied downloads, expired links, content types.
- [Functions](https://sovaria.in/docs/troubleshooting-functions): Refused calls, errors and timeouts, outbound hosts, secrets, triggers.
- [Realtime](https://sovaria.in/docs/troubleshooting-realtime): Close codes, missing messages and change events, presence.
- [Organization and plan](https://sovaria.in/docs/troubleshooting-platform): Plan limits, invitations, member permissions, keys, origins.

Every error response has a `detail` (a sentence, or an object with a `code`). Gateway errors also carry a `trace_id`, and every response has an `X-Request-ID` header — include it when you contact support. The full list of codes is in [the HTTP API reference](https://sovaria.in/docs/http-api).

## The browser says CORS error, or the API returns 403 ORIGIN_NOT_ALLOWED

- **Cause:** the site's origin (scheme, host and port) isn't in the project's allowed origins. Local development on a port is only allowed if `http://localhost:*` is listed.
- **Check:** the browser's network tab shows the `Origin` request header; compare it with **Project settings → API → Allowed origins**.
- **Fix:** add the exact origin, or `https://*.yourdomain.com` for subdomains. See [Allowed origins (CORS) for browser apps](https://sovaria.in/docs/allowed-origins).

## 401 right after signing in

- **Cause:** the session expired and wasn't refreshed, or the app is using a different project's URL or key.
- **Check:** the project URL and anon key both come from **Connect** for the same project.
- **Fix:** keep tokens across reloads as shown in [Connect your app](https://sovaria.in/docs/connect-your-app); sign in again if the refresh token was revoked.

## 403 NO_POLICY_DEFINED or a policy denial on a table

- **Cause:** no access policy decides for the table and its row-level security isn't enabled **and** forced, or a policy denies this caller.
- **Check:** `sov sim run --resource public.<table>` shows which check stopped the request for each user type.
- **Fix:** follow [Row-level security and access](https://sovaria.in/docs/row-level-security); then re-run the simulation.

## 403 PLAN_LIMIT_REACHED, PLAN_QUOTA_EXHAUSTED or PLAN_FEATURE_REQUIRED

- **Cause:** the action needs a plan feature, or a limit or monthly quota is used up. The body names the `limit_key`, the current `limit`, `used` and the `required_plan`.
- **Fix:** upgrade, buy an add-on where one exists, or wait for `resets_at`. See [Plans, usage and limits](https://sovaria.in/docs/plans-and-limits) and [Plan limits](https://sovaria.in/docs/plan-limits).

## 429 RATE_LIMIT_EXCEEDED

- **Cause:** too many requests for the project or the caller.
- **Fix:** wait `Retry-After` seconds and retry with exponential backoff; cache reads that don't change often.

## 409 IDEMPOTENCY_IN_PROGRESS

- **Cause:** a request with the same `Idempotency-Key` is still being processed.
- **Fix:** retry with the **same** key after a moment — the first request's result is returned, so nothing happens twice. The SDKs retry this for you.

## 409 IDEMPOTENCY_OUTCOME_UNKNOWN

- **Cause:** an earlier request with the same `Idempotency-Key` was sent but its answer was lost (the server timed out or failed after receiving it), so it may have been applied. The key stays taken for an hour so a retry can't apply it twice.
- **Fix:** check whether the change happened (read the row, document or payment). If it didn't, send it again with a **new** key. The SDKs stop and show this error instead of retrying.

## 503 RESOURCE_BUSY or PROJECT_MAINTENANCE

- **Cause:** another change to the same thing is in progress, or the database is starting.
- **Fix:** retry after `Retry-After` seconds.

## The Staging first switch says it needs an upgrade

- **Cause:** environments aren't included in Free.
- **Fix:** see [Environments, staging and deploying to production](https://sovaria.in/docs/environments-and-staging) for plans and the extra-environment add-on.
