---
title: Status and logs
description: Find a failing route or missing log lines, and understand a 401 your code never sent, SIGTERM lines, a crash loop, an old base image, and no migration applied.
slug: /troubleshooting/status-and-logs
order: 4
visibility: public
redirects_from: []
---

# Status and logs

Each entry starts from what `read_status`, `read_logs`, or a request to your application returns. The [`read_status` reference](/cloud/reference/actions/read-status/) describes every member of the status. [Read the status](/cloud/getting-started/deploy-an-application/#5-read-the-status) describes how to wait for a deploy to end. [Read logs and counters](/cloud/guides/read-logs-and-counters/) describes every [log source](/cloud/concepts/glossary/#log-source-and-store-source).

## My app is slow

Name the app, environment, route, and time of a slow request. Read [logs and counters](/cloud/guides/read-logs-and-counters/) for that window. Keep the request ID so you can find the matching entries.

If the first request after idle was slow, compare it with a later request to the same safe route. Check which version was serving at the time. If only one part is slow, measure its database query or outside call in development.

## My app stopped answering

**Cause.** If the visitor sees **This app is paused**, the platform is blocking requests because of an account pause. The page returns HTTP 429. A client that receives JSON sees `account_paused`. The status code alone leaves the cause open. The application quota refusal `usage_over_quota` also returns 429.

If the app simply stopped answering, check for a halted environment, a sleeping server, or a failed deploy. An account pause and an environment halt can happen at the same time. When both are present, the visitor sees the account pause first.

**Check.** Note the hostname the visitor used and the time and time zone of their first failed request. Call `read_account` to see which account your connection uses. Find the app in that account's `tzcloud_list_applications` results and match the application ID and hostname. If the app is missing, confirm the owning account before reading its balance.

Call `read_status` with that application ID and the affected `environment`. Check the environment's `halted` status, serving version and latest operation. For a custom hostname, check the application's custom domain in the full status response.

Call `read_balance` on the same account connection. It reads the current UTC month. Check `state.paused`. If it is missing or null, the pause is still unknown. `state.pause_recorded_at` gives the time the warning recorded the pause threshold. It can remain after the pause ends. Read the app's status and the account's balance together:

- **Account pause.** `state.paused: true` confirms the account pause. The app can show a serving version while requests are refused.
- **Environment halt.** Read `halted.at` and `halted.by`. These tell you when the environment stopped and distinguish an owner halt from a platform halt of idle development. Check the other environment separately if it is affected.
- **Sleeping server.** A safe request can wake a sleeping server. A restarting copy can also show `Idle`, and a shutdown line alone leaves the cause unknown. Compare `last_end` and the time of the first failure with the container and router logs. See [shutdown messages](#the-logs-show-sigterm-lines-after-a-promote-or-while-the-application-is-idle) and [a 502 followed by recovery](#a-request-returns-502-and-the-application-then-works-again).
- **Failed deploy.** Compare the latest operation with the serving version. A previous version can still be serving even if the new deploy failed. See [Deploys](/cloud/troubleshooting/deploys/) for health checks and refusal details.

**Remedy.** If the account is paused, read [When the account pauses](https://dev.turnzero.ai/turnzero/guides/balance-and-usage/#when-the-account-pauses) for what stays available and when the pause ends. Then [check the affected app and route](#confirm-the-app-is-serving-again). Use the [Free Allowance estimate](/cloud/guides/stay-inside-the-monthly-free-usage/#2-count-what-the-app-will-use) for two forecasts. Estimate a full UTC month after service resumes and the rest of the current UTC month from an assumed resumption time. State that time and how long you expect the server to be awake in each forecast.

For an owner halt on an active account, ask the owner about [resuming the affected environment](/cloud/guides/manage-versions-and-environments/#halt-and-resume).

### Confirm the app is serving again

For an account pause, call `read_balance` again. When it shows `state.paused: false`, read status for the same app and environment. If an owner halt remains, ask the owner about resuming that environment.

Send one request that leaves data unchanged to the affected route on the same hostname. Report what the request shows. If you cannot check that route safely, report what you could verify and ask the owner how to check it. The pause's end time appears in `state.paused_until` or in the refusal's `detail`. Use that time for the account pause. Check each route before reporting that it answers.

## The deploy succeeded but a route responds with a 500

**Cause.** A server application's deploy succeeds when the application starts, its health path returns 200 three times in a row, and any smoke paths the manifest lists pass. The health check calls that one path, and the smoke check calls only the listed paths, so a route neither calls can still fail. The router keeps individual records for a limited number of 5xx responses, the server errors from 500 to 599. Its per-minute counts include failures beyond the individual record limit.

**Check.** Call `read_status` for the environment. For failures the read found, `summary` gives the number of records and the number of different paths. `application.server_errors` lists up to twenty paths with their record counts, last statuses, and last failure times. If its `read` member is `skipped`, a deploy is running, so read again when it ends. Use `application.server_errors.counted_through` to judge recent failures: a request after that time may not be counted yet.

Read again before treating a missing recent failure as zero. If the path is absent, look for it in the router's individual `answered_5xx` records. Use the router's per-minute counts to check failures beyond the individual record limit.

For a server deploy, the success response and the command's `checked:` line describe the health and smoke paths requested; no other route was checked. When no health or smoke check ran, the command's line says so; request the pages or routes yourself.

**Remedy.** Read the application's output for the failing path. Use `read_logs` with `source: "container"` for a server's console, `source: "pool"` for a function's console, or `source: "app"` for records written through the Logging package.

If the version now serving production introduced the error and an earlier version worked, [roll back to that version](/cloud/guides/manage-versions-and-environments/#roll-back) with the owner's agreement. To fix the fault in the new version, change the route and deploy the corrected build. After the switch, check the affected route if it leaves data unchanged. If the route writes data or you cannot tell what it changes, agree on a safe check with the owner first. The `server_errors` member counts from the serving version's start, so a fixed route leaves the list.

To have each deploy request the route before the new version starts serving, list it in the manifest's `smoke_paths`. List each such route you add later there too, as [Checking your other routes](/cloud/concepts/the-deploy-health-check/#checking-your-other-routes) describes. [The failing paths in the status](/cloud/guides/read-logs-and-counters/#the-failing-paths-in-the-status) describes every member.

When a log read returns the record of a 5xx response, its `detail` can give the source and time window to check. For a server use `container`, and for a serverless function use `pool`. Check whether the version's console lines are still available. [From a 5xx record to the error your application wrote](/cloud/guides/read-logs-and-counters/#from-a-5xx-record-to-the-error-your-application-wrote) follows it to the stack trace.

## A log read with source app comes back empty though your code prints lines

**Cause.** The `app` source holds only what your application writes through the [Logging package](/cloud/backend-packages/logging/). Lines your code prints with `console.log` or `console.error` go to `container` for a server or `pool` for a serverless function. A static site has no function console.

**Check.** The empty response's `detail` says the `app` source holds only the Logging package's records. A `read_logs` call with `source: "container"` and the same window returns a server's printed lines if they are still retained. For functions, use `read_logs` with `source: "pool"` and the same window.

**Remedy.** Read printed server lines with `source: "container"`. For a serverless function, use `source: "pool"` or omit `source`. For records the platform keeps and can filter, write them through the Logging package and read them with `source: "app"`. If the `container` read is empty too, its `detail` says why. For example, the running copy scaled to zero, or the lines have not arrived yet. [Why a read comes back empty](/cloud/concepts/how-log-records-arrive/#why-a-read-comes-back-empty) describes each case.

## A request receives a 401 that your code never sends

**Cause.** Under an `invited` or `workforce` audience, the [serving router](/cloud/concepts/glossary/#serving-router) checks each request before your application sees it. The serving router is the platform process that receives every request to your hostnames. It refuses a request with no live session in the application's [realm](/cloud/concepts/glossary/#realm), such as one whose bearer token is missing or no longer valid. On a path listed in `session_free_paths`, the audience does not require a session. The router still checks a bearer if one is sent. A refused request never reaches your code, so your own 401 branch never runs on the platform.

**Check.** The response is `401` with `error: "authentication_required"`, and its `detail` opens with "The serving router refused this request before the application". An ordinary page visit without a session is sent to sign-in. If the router cannot verify a bearer, it returns the same 401 error with an `invalid_token` bearer challenge and does not redirect.

**Remedy.** For a browser, sign in again. A native app can use a valid refresh credential at the realm's token endpoint and then send the new bearer. To test your application's own 401 and 503 branches, run them where the serving router does not run. [Public or workforce for a backend that verifies the bearer](/cloud/guides/sign-in-from-a-native-app/#public-or-workforce-for-a-backend-that-verifies-the-bearer) gives the two places: offline tests on the Account package's test double, and a local run with the [run line](/cloud/concepts/turnzero-command/#the-run-line), `turnzero run --origin https://dev.turnzero.ai`.

## `read_status` shows the production state while development deploys

**Cause.** A `read_status` call with no `environment` argument describes production in its top-level members, whichever environment is deploying. The top-level `state`, `version`, and `hostname` are then production's. Each environment's own record, including the development deploy, is in the `environments` object.

**Check.** The top-level `environment` member is `production`. The `summary` gives each environment its own sentence, then says that the top-level members describe production. `environments.development.deploy.state` is `deploying`, and its `step` shows where the deploy is.

**Remedy.** Call `read_status` with `environment: "development"` and `wait_seconds` until the top-level `state` leaves `deploying`. The top-level members then describe development, and the summary says so. The `next` call a deploy returns already names the deploy's environment, so make that call as given.

## `read_status` says the version runs on an older base image

**Cause.** Each deploy builds an image of your application on the platform's base image. The platform updates that base image from time to time, often for security fixes. A running version keeps the base it was built on. The platform never rebuilds it for you.

**Check.** In `read_status`, each environment's `base` member gives `built_on`, the base the serving version was built on, and `current`, the base the platform builds on now. `stale` is `true` where they differ, `false` where they match, and `null` where no version serves or its base was not recorded. `fixes` is `critical` or `high` where the newer base carries fixes of that severity. Where the base is stale, a `base_apply` sentence beside it says so. In `list_versions`, the serving version's row gives the same `fixes`.

**Remedy.** Deploy again, even with the same zip. A deploy builds a new image on the current base. On an application with two environments, production gets the new base when you deploy to development and then promote that version. A promote carries the image of the version it promotes. A restart keeps the old image, so it does not help.

## The logs show SIGTERM lines after a promote or while the application is idle

**Cause.** These shutdown lines are normal. During a promote, or a deploy that replaces a running version, the platform stops the old version's container with `SIGTERM`. A [container app](/cloud/concepts/glossary/#container-app-and-pod) that scales to zero while idle is stopped with `SIGTERM` too. In either case, `npm` can print `npm error` lines as it ends.

**Check.** Call `read_logs` with `source: "container"`. Each line from the container being replaced has `[retiring]` after its stream. Each line an idle-stopped container wrote from the stop onward has `[idle-stop]` there instead. A line from the new version is never marked `[retiring]`. If the environment is still idle when you read, the `detail` says the last lines are an idle stop.

**Remedy.** None is needed. The serving version keeps responding, and the next request after an idle stop starts the application again. A read within about a minute of the stop may leave its lines unmarked, so read again. A pod never marks an idle stop. Once a pod has ended, the lines kept from it are marked `[pod-ended]` instead.

## `read_status` shows `CrashLooping`

**Cause.** The application's copy keeps exiting soon after it starts, so the hosting platform keeps restarting it. `compute_state` reads `CrashLooping` once the copy has restarted five times or more and is not running. It must also have last stopped within ten minutes, or be waiting out a delay before its next restart. `compute_restarts` gives the restart count. The platform never halts the application for it. The restarts go on until the code starts cleanly.

**Check.** Call `read_logs` with `source: "container"`. The last lines before each restart usually name the error, such as a missing setting, a failed database connection, or an exception at startup. Where the environment's `not_stored` in `read_status` lists a setting, that setting has no stored value, and the code may be exiting without it.

`read_status` shows the state on both a pod and a container app. The platform also writes a `warn` event, `crash loop`, to your application's log stream, counted as `warn.crash_loop`. The event names the copy, its restart count, and its last exit code where one is known.

On a pod, the event is written when the copy begins crash-looping. If the same copy keeps crash-looping, it can be reported again after seven days. On a container app, it is written once a day while the copy keeps crash-looping, and the count is the copy's stops in the last hour.

**Remedy.** Fix the cause in the code or store the missing setting, then deploy again. `compute_state` returns to its usual word once a copy starts and stays up.

## Database connections are full or queries are slow

Call `read_status` with `database_reading: true` for the application. Look at the reading for the environment with the problem. Compare its connection counts with the role’s limit and look for sessions that are still active or idle inside a transaction. See [Check database size and connections](/cloud/guides/add-a-database/#check-database-size-and-connections) for what the snapshot can show.

## A request returns 502 and the application then works again

**Cause.** The application process may have stopped while the request was in flight. If the router reported `upstream_ended`, the process stopped before response headers reached the client. One possible cause is that the process exceeded its memory limit and the platform restarted it.

For a reused connection on a pod, the intermediary may resend a bodyless `GET`, `HEAD`, `OPTIONS` or `TRACE` once to the restarted process if the first stops before sending response headers. A single failed request can account for two restarts, and a request with a body that reached the stopped process is sent once.

**Check.** Call `read_status` for the environment that served the request. Read `last_end` at the top level for the environment the call describes, or under that environment in `environments`. The brief answer includes it.

While a pod copy waits to restart after it ends, `compute_state` can read `Idle`, as it does when the environment sleeps, so check `last_end` for a recorded stop. After five or more restarts, a copy that is still down can read `CrashLooping`, for example when the cluster is delaying its restart.

For a pod, `last_end` gives the current copy's latest process end from `source: "pod_status"`. Compare `end.ended_at` with the time of the failed request. In `end`, `reason` gives the cluster's reason, such as `OOMKilled` for a memory end. The same record gives `exit_code` and the pod's restart count, `restarts`. `compute_restarts` can be null after a restart because it counts restarts only while the copy is `CrashLooping`.

If `end` is null, the current pod has no recorded end since `copy_started_at`. When a new pod replaces it, the previous pod's end drops out of the status. `last_end` is null when pod status cannot be read.

For Shared 1 GB or unlimited production, `last_end` reads the container provider's termination log. It gives `source: "system_logs"` and `copy_started_at: null`. It shows the newest end in the last hour or since the last deploy, promote or restart, whichever is later. `restarts` counts ends in that window.

A termination can take a few seconds to appear. The platform holds the log result for a minute and returns `last_end: null` if it cannot read the log within three seconds. An empty window gives `end: null`. During a deploy, promote, rollback, or restart, the window can begin at the read itself. Wait for the operation to settle and read again, or check logs for the time of the failure. The provider might report `ProcessExited` and exit code 137. That record alone cannot tell you whether the process ran out of memory.

For an end absent from `last_end`, call `read_logs` with `router` as the source for the time of the failure. The `upstream_ended` record tells you when the request was cut. Look in the container logs for clues about why the process stopped.

**Remedy.** If the process ran out of memory, reduce how much the route holds in memory at once. For production, you can also choose a size with a higher memory limit. Development uses its own memory limits. See [CPU and memory](/cloud/concepts/how-the-plans-differ-technically/#cpu-and-memory).

## The console says no migration was applied at a start

**Cause.** The migration function applies each file once and records it in the `schema_migrations` table. At a start where every file is already recorded, it applies none, and the start code prints `migrations: none pending at this start`. This happens at every restart, and when a copy wakes from its idle stop. It also happens at a deploy after a local run applied the file to the same database, including a first deploy to development.

Where the environment runs as a pod, the live console contains only the lines of pods that still exist. A pod that scaled to zero, or one a deploy replaced, leaves only each process's first and last lines, marked `[pod-ended]`, for a read's window. So the start that applied the file may be missing, even on a first deploy. It is missing where the migration ran as its own step of `start`, or where that start is older than the read's window.

**Check.** Request a route that exercises the change made by the migration. To confirm a particular migration ran, check its entry in `schema_migrations`, the history table used by the Database package and both runners in [Keep the schema as migrations](/cloud/guides/add-a-database/#4-keep-the-schema-as-migrations), and check the expected schema change. If your app uses another migration tool, check that tool's history instead. `read_status` with `tables: true` lists table names; a table's presence alone does not prove that every column, index or data migration ran.

Or run `SELECT count(*) FROM <table>` with `query_database`. It returns a count where the table exists, and the refusal `query_failed` with `sqlstate` `42P01` where it does not ([Read your data](/cloud/guides/add-a-database/#6-read-your-data)). If the console still has the lines of the start that applied the file, that start printed the file's name.

**Remedy.** If the recorded migrations and expected schema match, no change is needed. If a migration is missing, check that its file was deployed and that startup reads the correct folder before the server listens. For a later schema change, add a new migration file. After production has started with a migration, never edit or rename that file. For a migration recorded only in development, follow the linked reset procedure before changing it. [Keep the schema as migrations](/cloud/guides/add-a-database/#4-keep-the-schema-as-migrations) explains the function.

## A `read_logs` or `read_status` call reports that the tool call failed

**Cause.** "Tool call failed" is your AI assistant's own message for a call that got no response. It carries no response from the platform, `reference`, or refusal name. The outcome of the call is unknown.

**Check.** The message holds no refusal name and no `reference`.

**Remedy.** A read such as `read_logs` or `read_status` changes nothing, so where one draws no answer or your tool reports the call failed, call it again. A call such as `deploy` can change the application. [A call that gets a response from something other than the platform](/cloud/troubleshooting/deploys/#a-deploy-promote-or-rollback-call-gets-a-response-from-something-other-than-the-platform) says how to tell whether it started.

## A call is refused with `cell_timeout`

**Cause.** The [hosting cell](/cloud/concepts/glossary/#hosting-cell) that runs your application did not respond in time, so the call could not finish. Nothing in your request was wrong. Any call can meet it, `read_status` and `read_logs` most often.

**Check.** The response is `503` with `error: "cell_timeout"`. Its `detail` says the hosting cell did not respond in time, and ends with a `reference`.

**Remedy.** Repeat a read after a short wait. For a `deploy` or `promote`, [check whether it started](/cloud/troubleshooting/deploys/#a-deploy-promote-or-rollback-call-gets-a-response-from-something-other-than-the-platform). For another write, check its own outcome or current state. Repeat a write only when the evidence shows it did not start. If the refusal persists, report it and quote the reference.
