> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sevalla.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These are the docs for Sevalla, a platform for deploying applications, databases, static sites, object storage and load balancers. The dashboard is at https://app.sevalla.com.
> Bold text in steps is an exact dashboard label.
> To act on a Sevalla account, prefer the Sevalla MCP server (https://mcp.sevalla.com/mcp, see https://docs.sevalla.com/ai-agents/overview.md), then the Sevalla CLI (https://docs.sevalla.com/developer-tools/cli.md), then the REST API (https://api-docs.sevalla.com, OpenAPI spec at https://api.sevalla.com/v3/openapi.json).
> Every page index is at https://docs.sevalla.com/llms.txt.

# Troubleshoot HTTP errors

> Find who returned an HTTP error for an application (your code, Sevalla or Cloudflare) and fix it: 403, 404, 502, 503, 504, Cloudflare 52x errors, upstream connect errors and redirect loops.

An HTTP error on an application's domain comes from one of three places: your application, Sevalla (IP restrictions, maintenance mode, hibernation, or the ingress that routes requests to the web process), or Cloudflare when it can't get a valid response. The status code and the page's body tell them apart. This page lists the errors Sevalla and Cloudflare return, what each means on Sevalla, and the fix.

## Who returned the error

| What you see | Who returned it |
| - | - |
| Your framework's error page, or a response your code builds | Your application. Check its [runtime logs](/applications/logs) |
| A plain `Forbidden` with status `403` | Sevalla's [IP restrictions](#403-forbidden) |
| A maintenance page with status `503` | [Maintenance mode](#503-service-unavailable) |
| A short plain-text page with `502`, `503` or `504`, or `upstream connect error`, `no healthy upstream` | Sevalla's ingress: the web process didn't answer |
| A Cloudflare-branded page with an error number (`520`, `521`, `522`, `524`…) and a Ray ID | Cloudflare, which couldn't get a valid response in time |

The [access logs](/applications/logs) record the status of every request, and the **Status codes** chart on the [Analytics](/applications/analytics) tab shows when errors started.

## 403 Forbidden

**Symptom.** Requests return `403`.

**Cause.**

* A plain body `Forbidden` means the application's [IP restrictions](/applications/networking#ip-restrictions) blocked the visitor's address. With an allowlist, every address not on it is blocked; with a denylist, the listed ones.
* Any other `403` comes from your code or your web server: it can't read the files (file permissions), or an `.htaccess` rule (`Deny`, `RewriteRule`, `FilesMatch`) or a document root that points at the wrong folder refuses the request.

**Fix.**

* For IP restrictions, check the **IP restrictions** section on the **Networking** tab and add or remove the address. Find your own address with a site such as `https://ifconfig.me`.
* For file permissions, make files readable (`644`) and folders traversable (`755`) in your build.
* For the server configuration, fix the rule or the document root. With Buildpacks and Apache, the application is in `/workspace`, so point the document root at its public folder, for example `heroku-php-apache2 public/`.

## 404 Not Found

**Symptom.** Every path of a domain returns `404`, including `/`.

**Cause.** The request doesn't reach the web process: [HTTP traffic is turned off](/applications/networking#turn-http-traffic-off), the domain isn't active yet, or the application has no successful deployment.

**Fix.** Check that **Expose HTTP traffic** on the **Networking** tab shows the domain as enabled, that the domain is **Active** on the **Domains** tab (see [Troubleshoot custom domains](/domains/troubleshooting)), and that the latest deployment succeeded. A `404` on some paths only comes from your application's routes.

## 500 Internal Server Error

**Symptom.** Requests return `500`, usually with your framework's error page.

**Cause.** An unhandled error in your application while it answered the request. Common causes are a missing or wrong [environment variable](/applications/environment-variables) and a database the application can't reach.

**Fix.** Find the stack trace in the [runtime logs](/applications/logs) at the time of the request: pick the **Error** level and the web process. For database errors, see [The application cannot connect to a database](/applications/troubleshooting/runtime-errors#the-application-cannot-connect-to-a-database).

## 502 Bad Gateway and upstream connect error

**Symptom.** Requests return `502`, or a page with:

```text theme={null}
upstream connect error or disconnect/reset before headers. reset reason: connection failure, transport failure reason: delayed connect error: 111
```

**Cause.** Sevalla reached the web process's instance but nothing accepted the connection on the [web process port](/applications/networking#web-process-port). The server listens on another port, listens only on `localhost`, isn't listening yet, or crashed while answering.

**Fix.**

1. Make the server listen on `0.0.0.0` and on the `PORT` environment variable, or set the **Port** on the **Networking** tab to the port your server uses.
2. Check the runtime logs for crashes during requests.
3. Add a [readiness probe](/applications/processes#health-checks) so that instances get traffic only once they listen.

## 503 Service Unavailable

| Cause | How you recognize it | Fix |
| - | - | - |
| [Maintenance mode](/applications/maintenance-mode) is on | A maintenance page on every path and domain, with a `Retry-After: 300` header | Turn maintenance mode off on the **Settings** tab |
| No instance is ready | `no healthy upstream` or `503 Service Temporarily Unavailable` on every path. The web process has 0 instances, is crashing, or is still starting | Check **App health** and the **Processes** tab. See [Troubleshoot runtime errors](/applications/troubleshooting/runtime-errors) |
| The application is waking from [hibernation](/applications/scaling#hibernation) | The first request after an idle period. Sevalla holds requests for up to about 3 minutes while the application starts; a request with a body over 50 MB or without a `Content-Length` header, or one the application doesn't answer in that time, gets the `503` | Retry after a moment, make the application start faster, or turn hibernation off for applications that receive uploads after idle periods |
| The application is [suspended](/applications/settings#suspend-an-application) | The application's status reads **Suspended** | Activate the application |
| Your application returns it | Your own error page, often while a dependency is down | Check the runtime logs |

## 504 Gateway Timeout and Cloudflare error 524

**Symptom.** Long requests fail with `504 Gateway Timeout`, or Cloudflare's `Error 524: A timeout occurred`.

**Cause.** Cloudflare waits up to 185 seconds for your application to start answering a request. A slow query, an external API that hangs, or a long task inside the request exceeds it.

**Fix.** Find the slow requests in **Slowest requests** on the **Analytics** tab and make them faster: add database indexes, cache results, call external services with timeouts. Move work that takes minutes to a [background worker](/applications/processes#background-workers) and return a response right away. If the process is at its CPU or memory limit, give it a [larger size or more instances](/applications/scaling).

## Cloudflare errors 520, 521 and 522

These Cloudflare pages mean Cloudflare got no valid response from Sevalla:

| Error | What it means on Sevalla | Fix |
| - | - | - |
| `520` Web server is returning an unknown error | The web process closed the connection or sent an invalid or empty response, for example because it crashed mid-request or sent response headers that are too large (often too many cookies) | Check the runtime logs at the time of the error, and reduce the response headers |
| `521` Web server is down | Cloudflare couldn't connect to Sevalla for the application | Check [Sevalla's status page](/platform/system-status). If it persists, [contact support](/support/get-help) with the Ray ID |
| `522` Connection timed out | Cloudflare's connection to Sevalla timed out | Same as `521` |

## Too many redirects

**Symptom.** The browser stops with `ERR_TOO_MANY_REDIRECTS`, or the page redirects to itself.

**Cause.** The application forces HTTPS by looking at the connection it receives, which isn't HTTPS, so it redirects every request, including the ones that already used HTTPS. Sevalla already redirects HTTP to HTTPS for every domain.

**Fix.** Make your framework trust the proxy headers so it sees `X-Forwarded-Proto: https`, for example `app.set("trust proxy", true)` in Express or the `TrustProxies` middleware in Laravel, or remove the application's own HTTP-to-HTTPS redirect. See [Request headers](/applications/http-headers). A redirect loop on a custom domain can also come from your DNS provider's own proxy settings; see [Troubleshoot custom domains](/domains/troubleshooting).

If you can't find the cause, [contact support](/support/get-help) with the URL, the time and, for Cloudflare errors, the Ray ID.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.