# Troubleshooting

These instructions apply to the current Admin Console.

{% 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 %}

Start with the first failing step in the [quickstart](https://docs.contextual.io/build/contextual-workers/quickstart.md). Keep the CLI configuration ID, tenant ID, Worker ID, saved version, and image reference with your notes.

## Workers Is Missing or the API Denies Access

Workers must be enabled for the tenant. A CLI login alone does not enable the feature. Check the selected tenant, then [contact Contextual support](mailto:help@contextual.io) to confirm enablement and permissions.

```sh
ctxl config current --json
```

The `--config-id` flag selects the CLI configuration used by a Worker command. The selected configuration can differ from the machine's default CLI configuration. Check the configuration ID on the failing command.

## The CLI Does Not Recognize a Command

An error such as `Command workers not found` or `workers configure-docker is not a ctxl command` means the installed CLI does not include Worker commands. Update the Contextual CLI, use the plural `workers` group, and check the command's help:

```sh
npm install -g @contextual-io/cli
ctxl --version
ctxl workers --help
ctxl workers create --help
ctxl workers configure-docker --help
```

The `npm install` command updates your global CLI installation. If a Worker command still fails, include the failing command, error, and CLI version in a [failure report](#report-a-failure).

If `workers configure-docker` reports that `docker-credential-ctxl` is not on your `PATH`, check your npm executable directory. Docker must be able to find `docker-credential-ctxl` on `PATH`.

## Image Build or Push Fails

1. Check that the Docker engine is running and that you are in the intended build directory.
2. Run the quickstart's local build. The CLI builds for `linux/amd64`. Use `--platform linux/amd64` for the local Docker build.
3. If authentication fails, select the intended CLI configuration, sign in again with `ctxl config login`, and rerun `ctxl workers configure-docker`.
4. Use the image reference printed by `workers images push`. Workers accept only images from your organization's image host or the platform's, such as `images.<org>.my.contextual.io/<name>:<tag>`. A local Docker image ID cannot be used as the image reference. See [Image References](https://docs.contextual.io/build/contextual-workers/about-workers.md#image-references).

If the API reports an unavailable registry, [contact Contextual support](mailto:help@contextual.io) and include the error and tenant ID.

A push of large layers over a slow connection can fail with `timeout awaiting response headers` or `failed commit on ref layer-sha256:…`. Docker's containerd image store and BuildKit send each layer in one request, and the client can stop waiting for the response before its local buffers finish sending. The layer often arrives anyway. Run the push again: layers that already arrived are skipped. If it keeps failing, push from a faster connection, such as a CI runner.

## Compose Validation Fails

Check `x-contextual.version: 1`, the supported Compose keys, and a readiness check for the selected public service: an image `HEALTHCHECK`, a Compose `healthcheck`, or `x-contextual.http_healthcheck`. A Compose service is public only when it sets `x-contextual.public`, even when it's the only service in the file. Services in the same Worker share a network; avoid conflicting ports. Environment names that start with `CONTEXTUAL_` are reserved. Custom Compose files do not support `${…}` variables; write `$$` for a literal `$`.

Use the [x-contextual Specification](https://docs.contextual.io/build/contextual-workers/x-contextual-specification.md#rules) to interpret the validation error. For managed templates, check the name, version, and declared options against the console's **Managed worker** fields.

## The Worker Saves but Does Not Serve Requests

1. Open the Worker in the admin console and select **Deployment**. Check readiness, instance status, and restart information.
2. Inspect the instances with `ctxl agents instances <worker-id> --config-id <config-id> --pretty`.
3. Read the container output with `ctxl workers logs <worker-id> --config-id <config-id>`. If a container restarted after a crash, add `--previous` to read the run before the restart.
4. Check that the app listens on `0.0.0.0` at `PORT` and returns success from the application's readiness endpoint. See the quickstart's [application requirements](https://docs.contextual.io/build/contextual-workers/quickstart.md#2-create-the-application-files).
5. Copy the **Public Worker URL** from the deployment view and request both the health endpoint and an application endpoint.

## Instance Details or Restart Fails

The instance list on the **Deployment** view has **Instance details** and **Restart** actions.

* `Couldn't load instance details` appears in the details dialog when the console can't load the instance's latest details. The dialog still shows the details from the instance list. Select **Retry**.
* `Couldn't restart instance` appears above the instance list if a restart request fails. **Restart** requests deletion asynchronously. An unscheduled Worker can create a replacement if its desired instance count requires one. Scheduled Workers do not guarantee an immediate replacement.

Read the message shown with the error. Then check whether the instance is still listed in **Deployment**, or list the current instances with `ctxl agents instances <worker-id> --config-id <config-id> --pretty`. If it keeps failing, include the error in a [failure report](#report-a-failure).

## The Application Cannot Write Files

Errors such as `EROFS: read-only file system` or `EACCES: permission denied` usually mean the application writes outside its writable paths. The root filesystem is read-only, and processes run as user ID 10001, not the image's `USER`. Write to `/tmp` or a Compose named volume. Point tools that write to the home directory or a cache, such as package managers, at `/tmp`. See [Runtime Environment](https://docs.contextual.io/build/contextual-workers/about-workers.md#runtime-environment) for the storage limits.

## Large Requests Fail or Time Out

An HTTP Worker accepts request bodies up to 1 MB and waits 30 seconds for a response by default. A larger body returns `413`, and a slower response returns `504`. Set the Worker environment variables `BODY_SIZE_LIMIT` (for example, `10mb`) and `HTTP_TIMEOUT_MS` (in milliseconds) to change these limits. For long-running work, use an event Worker instead. A managed HTTP Worker also answers `503` when its request slots and queue are full. See [Troubleshooting Managed Workers](https://docs.contextual.io/build/contextual-workers/managed-workers/troubleshooting.md#http-requests-fail-with-400-413-500-503-or-504).

## An Update Returns the Old Response

Check the saved Worker version and pinned image reference. Wait for the rollout and inspect the new instances before repeating the application check. An image push alone does not update the Worker's saved image selection.

If an update fails with a conflict, read the Worker again before retrying. Another change may have been saved while the image was building. If a command times out, inspect the saved configuration and deployment first; the write may have completed.

## Logs or Event Processing Are Missing

`ctxl logs` and the console's message logs show only platform-routed logs. A custom container's output never appears there. Read it with `ctxl workers logs <worker-id>`. A managed Worker's host always writes its logs to the `host` container's output, whether or not the tenant has its own log topic. See [Read Logs](https://docs.contextual.io/build/contextual-workers/contextual-cli.md#read-logs).

`ctxl workers logs` shows only replicas that exist now. An event Worker scaled to zero, or a replaced replica, has no container output to show.

An event Worker configured to scale to zero can have no replicas while the event backlog is empty. For failed processing, inspect the event errors. A managed event Worker has no dead-letter queue: a failed event is redelivered after the host restarts. See [Events and Schedules](https://docs.contextual.io/build/contextual-workers/connect-to-contextual.md#events-and-schedules).

A scheduled Worker follows a UTC cron schedule and has no public URL. The scheduled application must finish after each run. A run is stopped after 30 minutes and is not retried, and a tick is skipped while the previous run is still in progress.

## Local Data Disappears

Worker containers and volumes are temporary. Store durable state in Native Objects or an external service. Use local files only for data that the application can recreate after a replica is replaced. See [Runtime Environment](https://docs.contextual.io/build/contextual-workers/about-workers.md#runtime-environment).

## Report a Failure

[Contact Contextual support](mailto:help@contextual.io). Include the tenant ID, Worker ID, failing command or request, expected and actual results, time of the failure, and the Worker version and image reference. Remove credentials and private application data from the report.
