> For the complete documentation index, see [llms.txt](https://docs.contextual.io/documentation-and-resources/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.contextual.io/documentation-and-resources/components-and-data/contextual-workers/managed-workers/troubleshooting.md).

# Troubleshooting Managed Workers

Fix adapter image, packaging, deployment, and runtime problems in managed Workers.

{% hint style="info" %}
Contextual Workers are in early access and may not be available in your account. [Contact Contextual support](mailto:help@contextual.io) to request that Workers be enabled for your tenant.
{% endhint %}

For problems that apply to every Worker, such as CLI access, image pushes, and deployment readiness, see the general [Troubleshooting](https://docs.contextual.io/documentation-and-resources/components-and-data/contextual-workers/troubleshooting.md) page. Keep the Worker ID, template version, adapter version, and the failing command or invocation ID in your notes.

## The Adapter Image Cannot Be Pulled

`docker pull` or a `FROM` line fails with `unauthorized`, `denied`, or `no basic auth credentials`.

1. Sign in again with `ctxl config login`. Then run `ctxl workers configure-docker --pretty`.
2. Check that `docker-credential-ctxl` is on your `PATH`.
3. Check the image name and version against [Get the Runtime Adapters](https://docs.contextual.io/documentation-and-resources/components-and-data/contextual-workers/managed-workers/runtime-adapters.md). Adapter images are under `images.contextual.io/worker/base/`.

If the pull still fails, [contact Contextual support](mailto:help@contextual.io) and include the image reference, tenant ID, and error.

## Copying the Library Fails with Permission Denied

Docker created the `.contextual` directory as root before the copy ran. Remove it, create it yourself with `mkdir -p .contextual`, and run the copy command again.

If an upgraded library still shows old methods, the new copy was nested inside the old directory. Delete the old copy and copy again, as [Get the Runtime Adapters](https://docs.contextual.io/documentation-and-resources/components-and-data/contextual-workers/managed-workers/runtime-adapters.md#copy-the-library-into-your-project) shows.

## `package` Refuses the Release

The `package` command refuses an output directory that already exists. Remove `.worker-image` before you package again.

The command also checks `worker.json` before it writes anything. Check that:

* `workerId` is lowercase words joined by hyphens, and `version` is a semantic version.
* Each handler name starts with a letter and lists `event`, `http`, or `cron`.
* `configSchema` is an object.
* For TypeScript, `entrypoint` names the `.cjs` bundle in the build output directory. For Python, it names a `.py` file in `src`, `main.py` by default.
* For Rust and Go, the second argument is the compiled `linux/amd64` binary.
* The build output directory has no symbolic links.

## Saving the Worker Fails

The platform checks a managed Worker's image and bindings when you save it:

* **"A managed host must depend on exactly one release-labelled application":** `IMAGE` isn't the `.worker-image` build that `package` produced. An image built straight from your source has no release label.
* **"Worker connection bindings must match the application's declared connections exactly":** `CONNECTION_BINDINGS` must bind exactly the aliases in `worker.json`'s `connections`.
* **A refused environment variable:** names that start with `CONTEXTUAL_` are reserved.

## The Worker Does Not Become Ready

1. Open **Workers > your Worker > Deployment** in the admin console and check both containers. A managed Worker runs an `app` container, your code, and a `host` container.
2. Read each container's output. Add `--previous` to read the run before a restart:

   ```sh
   ctxl workers logs <worker-id> -c app --config-id <config-id>
   ctxl workers logs <worker-id> -c host --config-id <config-id>
   ctxl workers logs <worker-id> -c host --previous --config-id <config-id>
   ```
3. Check for these common causes:
   * **The handler name does not match.** `HANDLER` must name a handler in `worker.json` that accepts the template's trigger.
   * **`CONFIG` isn't a JSON object**, or, for TypeScript, doesn't match `configSchema`. The TypeScript adapter checks the schema at startup. In Rust, Go, and Python, a missing value shows up as your handler's own error instead.
   * **The name or version does not match.** The name and version in your code must match `worker.json` in every language: the default export in TypeScript, and `Cargo.toml`'s version in Rust.
   * **The start hook takes longer than 60 seconds.** The host stops waiting for `start` after 60 seconds. Move slow setup into the handler, or make it lazy.
   * **`PLATFORM_SERVICES` is invalid.** The host does not start when a name in the option isn't a valid service name (letters and digits only), or when it grants `connectionsApi`. The host's output names the problem.

## A Capability Call Fails

Read the failure's `code` and `reason`:

| Code                     | What to Check                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `validation`             | The parameters. `issues` names each invalid one.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `authorization`          | The record type, connection, or attachment access. Records, attachments, and AI Search use the tenant's managed `native-object-api` connection. Check that connection's access to the requested object type. AI generation, AI uploads, tool sessions, and loading bound connections use the Worker's own OAuth client. For a failed call, inspect its error details. A 401 or 403 alone does not establish which permission or configuration needs changing. If the failure remains unresolved and appears to involve the Worker's managed credentials or permissions, follow [Worker Identity](https://docs.contextual.io/documentation-and-resources/components-and-data/contextual-workers/managed-workers/platform-services.md#worker-identity) to [contact Contextual support](mailto:help@contextual.io) with the relevant details. `api-configuration` records are always refused through generic record operations. For `services.request`, also check the failure's `reason`; see [Refusals](https://docs.contextual.io/documentation-and-resources/components-and-data/contextual-workers/managed-workers/platform-services.md#refusals). |
| `not-found`              | The type, record, attachment, Route, or AI Search profile ID                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `conflict`               | The record changed after you read its hash. Read it again.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `effect-outcome-unknown` | A write may have happened. Check before you retry.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `deadline`               | The call ran out of its own time, such as an AI generation's `timeoutMs`, 300 seconds by default. An HTTP request past `HTTP_TIMEOUT_MS` is a 504 response instead.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `platform`               | The platform or a provider failed or was busy. Retry only if `retryable` is true.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `contract`               | The host does not offer the operation (`unsupported-method`) or is not configured for it (`configuration`). Check that the template version matches your adapter version. See [Release Versions](https://docs.contextual.io/documentation-and-resources/components-and-data/contextual-workers/managed-workers.md#release-versions).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

A host fault is different: the host failed the call itself, or the bridge to it was lost. It is a `CapabilityError` in Rust, Go, and Python, or a plain `Error` in TypeScript, and it fails the invocation even if your code catches it.

## HTTP Requests Fail with 400, 413, 500, 503, or 504

* **400:** The request body ended before its declared length.
* **413:** The request body is larger than `BODY_SIZE_LIMIT`.
* **500:** The handler failed, or returned an invalid response: a status outside 200 to 599, an unknown field, or a body over 4 MiB. Read the `app` container's output.
* **503:** All of the replica's request slots were in use for longer than `HTTP_ADMISSION_TIMEOUT_MS`, or its queue was full. The response has `Retry-After: 1`. Add replicas, or raise `HTTP_CONCURRENCY` or `HTTP_QUEUE_CAPACITY`. Their sum must stay at most 101, or the host does not start. A replica that is shutting down also answers 503.
* **504:** The request passed `HTTP_TIMEOUT_MS`. Raise the deadline for slow operations, such as large attachment transfers or long AI generations. The effective limit is the lowest of every limit on the path: a long transfer can also be cut off by intermediate connections, even within `HTTP_TIMEOUT_MS`. Prefer short requests, and move long work to an event Worker.

## Events Are Processed More Than Once, or the Worker Keeps Restarting

Delivery is at least once. An unhandled handler failure stops the host without acknowledging the event, the container restarts, and the event is redelivered. The same happens if the replica stops before the event is acknowledged, or if an event's payload is not JSON or is larger than 8 MiB. There is no dead-letter queue, so an event that always fails makes the Worker restart repeatedly.

An idle app that doesn't answer the host also causes a restart. The host pings the app every 10 seconds and ends the connection after 30 seconds without an answer while the app is idle. Before each event or scheduled run, the app must answer within 5 seconds, or the host fails that event or run without sending it to the app. A handler that is running is not held to these checks, so a long call or a handler that blocks its event loop is fine up to the execution deadline.

Read the failure with `ctxl workers logs <worker-id> -c host --previous`. Make writes safe to repeat, using the event's `id` as the idempotency key. Catch failures that retrying cannot fix, log them, and return successfully.

## Logs Are Missing

The logger's entries go to the tenant log pipeline only when the tenant has its own `contextual/logs` topic. Read them with `ctxl logs <worker-id>`. The host always writes them to its own container output too, with the console logger's lines: `ctxl workers logs <worker-id> -c host`. Entries below the host's minimum level, `info` by default, are dropped. Output your code prints goes to the app container: `ctxl workers logs <worker-id> -c app`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.contextual.io/documentation-and-resources/components-and-data/contextual-workers/managed-workers/troubleshooting.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
