# Troubleshooting common errors

> Fix common pushq problems, from tasks not being delivered, 401, 403, 404 and 409 errors and failed webhook signature checks to endless retries and timeouts.

Source: https://pushqueue.dev/docs/guides/troubleshooting/

This troubleshooting guide lists pushq failures people actually hit, each as symptom, cause and fix: tasks that aren't delivered, API errors such as `401`, `403`, `404`, `409` and `413`, webhook signature verification failures, retries that never stop, and self-hosted server issues. Find your symptom in the headings below.

## Diagnose a task that isn't delivered

Start with the queue's stats and the task's attempt log. The queue `state`, the `scheduled_future` count and each attempt's `response_status` or `error_kind` (with `error_snippet`) point at the cause in most cases.


**TypeScript**

```ts
const stats = await pq.queueStats("emails");
console.log(stats.state, stats.pending, stats.scheduledFuture, stats.oldestDueAgeSeconds);

const task = await pq.getTask("emails", "welcome-user-42");
console.log(task.state, task.scheduleTime, task.dispatchCount);
for (const a of await pq.listAttempts("emails", "welcome-user-42")) {
  console.log(a.number, a.responseStatus ?? a.errorKind, a.errorSnippet, a.durationMs);
}
```

**Python**

```python
stats = pq.queue_stats("emails")
print(stats.state, stats.pending, stats.scheduled_future, stats.oldest_due_age_seconds)

task = pq.get_task("emails", "welcome-user-42")
print(task.state, task.schedule_time, task.dispatch_count)
for a in pq.list_attempts("emails", "welcome-user-42"):
    print(a.number, a.response_status or a.error_kind, a.error_snippet, a.duration_ms)
```

**Go**

```go
st, err := pq.QueueStats(ctx, "emails", "")
if err != nil {
	return err
}
fmt.Println(st.State, st.Pending, st.ScheduledFuture, st.ErrorsLast1m)

t, err := pq.GetTask(ctx, "emails", "welcome-user-42")
if err != nil {
	return err
}
fmt.Println(t.State, t.ScheduleTime, t.DispatchCount)
attempts, err := pq.ListAttempts(ctx, "emails", "welcome-user-42")
if err != nil {
	return err
}
for _, a := range attempts {
	fmt.Println(a.Number, a.ResponseStatus, a.ErrorKind, a.ErrorSnippet, a.DurationMS)
}
```

**Java**

```java
QueueStats s = pq.queueStats("emails");
System.out.println(s.getState() + " pending=" + s.getPending()
    + " future=" + s.getScheduledFuture() + " lag=" + s.getOldestDueAgeSeconds());

Task t = pq.getTask("emails", "welcome-user-42");
System.out.println(t.getState() + " " + t.getScheduleTime() + " " + t.getDispatchCount());
for (Attempt a : pq.listAttempts("emails", "welcome-user-42")) {
    System.out.printf("#%d status=%s kind=%s %s%n",
        a.getNumber(), a.getResponseStatus(), a.getErrorKind(), a.getErrorSnippet());
}
```

**.NET**

```csharp
QueueStats stats = await pq.GetQueueStatsAsync("emails");
Console.WriteLine($"{stats.State} pending={stats.Pending} future={stats.ScheduledFuture} lag={stats.OldestDueAgeSeconds}");

PushqTask task = await pq.GetTaskAsync("emails", "welcome-user-42");
Console.WriteLine($"{task.State} {task.ScheduleTime} {task.DispatchCount}");
foreach (var a in await pq.ListAttemptsAsync("emails", "welcome-user-42"))
    Console.WriteLine($"#{a.Number} {a.ResponseStatus?.ToString() ?? a.ErrorKind} {a.ErrorSnippet}");
```

**curl**

```bash
curl -s https://api.pushqueue.dev/v1/queues/emails/stats -H "Authorization: Bearer $PUSHQ_API_KEY"
curl -s https://api.pushqueue.dev/v1/queues/emails/tasks/welcome-user-42 -H "Authorization: Bearer $PUSHQ_API_KEY"
curl -s https://api.pushqueue.dev/v1/queues/emails/tasks/welcome-user-42/attempts -H "Authorization: Bearer $PUSHQ_API_KEY"
```

The [dashboard](https://pushqueue.dev/docs/guides/dashboard/) shows the same numbers and the attempt history on each task's page. Error codes below are the `code` field of the problem+json body, which every SDK exposes on its error type; see the [errors reference](https://pushqueue.dev/docs/reference/errors/).

## Tasks not being delivered

### Tasks stay pending because the queue is paused

**Symptom:** tasks are created but never delivered; stats show `state: "paused"` and a growing `pending` count.

**Cause:** a paused queue accepts new tasks but starts no deliveries.

**Fix:** resume the queue (`POST /v1/queues/{queue}:resume`). Queued tasks then go out at the queue's rate limits. See [pause and resume a queue](https://pushqueue.dev/docs/concepts/queues/#pause-and-resume-a-queue).

### Enqueue fails with failed_precondition: queue is disabled

**Symptom:** creating a task fails with `400 failed_precondition` and a detail like `queue "emails" is disabled`.

**Cause:** a disabled queue rejects new tasks and dispatches nothing. Running a task with `:run` is refused too.

**Fix:** resume the queue; resume also re-enables a disabled queue. See [queue states](https://pushqueue.dev/docs/concepts/queues/#queue-states).

### Tasks stay pending because they are scheduled in the future

**Symptom:** the queue is `running` but a task isn't delivered; stats count it in `scheduled_future`, and the task's `schedule_time` is later than now.

**Cause:** the task was created with `delay_seconds` or `schedule_time`. A common slip is passing milliseconds where seconds are expected, or a local time without a time zone.

**Fix:** check `schedule_time` on the task. To deliver it now, call `POST /v1/queues/{queue}/tasks/{task_id}:run`. See [scheduling and cancelling tasks](https://pushqueue.dev/docs/patterns/scheduling-and-cancelling/).

### Tasks are delivered slowly: rate limit or concurrency cap

**Symptom:** tasks go out, but more slowly than expected; `oldest_due_age_seconds` keeps growing.

**Cause:** one of the queue's limits is in effect:

- `rate_limits.max_dispatches_per_second` caps how fast deliveries start.
- `rate_limits.max_concurrent_dispatches` caps requests in flight. A slow handler fills every slot, and the queue then waits for responses.
- Your endpoint answered `429` or `503` with `Retry-After`, which pauses new deliveries on the whole queue for up to 30 seconds.
- On a self-hosted server, `dispatcher.global_concurrency` (default 512) caps in-flight deliveries across all queues.

**Fix:** raise the limit that binds, or make the handler respond faster. See the [rate limits guide](https://pushqueue.dev/docs/guides/rate-limits/) and [Retry-After and the queue cool-down](https://pushqueue.dev/docs/concepts/retries/#retry-after-and-the-queue-cool-down).

### Every attempt fails with connect, dns, tls or timeout: wrong base_url

**Symptom:** attempts have no `response_status` and an `error_kind` of `connect`, `dns`, `tls` or `timeout`.

**Cause:** pushq can't reach the target. Usually `target.base_url` (or the task's `url`) has a typo, the wrong port, or a host that is only reachable on your machine or private network. The hosted service can't reach `localhost`; use a public URL or a tunnel, or run [`pushq dev` locally](https://pushqueue.dev/docs/getting-started/local-development/).

**Fix:** read the queue and check `target.base_url`, then correct it with PATCH. The target is applied at delivery time, so tasks already queued use the new URL on their next attempt. See [the target settings](https://pushqueue.dev/docs/concepts/queues/#target-settings-base-url-method-headers-and-signing-secret).

### Relative path rejected: queue has no target.base_url

**Symptom:** creating a task with `path` fails with `400 failed_precondition`: `task uses a relative path but queue "emails" has no target.base_url`. Or tasks that were already queued fail with `error_kind: config`.

**Cause:** relative paths are resolved against the queue's `target.base_url`, and the queue has none, often because a PUT upsert left out `target` (see [Upsert wiped my target](#upsert-wiped-my-target-base_url-headers-or-dead-letter-queue)).

**Fix:** set `target.base_url` on the queue, or create tasks with an absolute `url`. Queued tasks pick up the fixed base URL on their next retry.

## Authentication errors: 401 and 403

### 401 unauthenticated on every API call

**Symptom:** every call fails with `401 unauthenticated` and `sign in or send a valid API key`.

**Cause:** the request carried no valid key. Check, in order:

- The header is `Authorization: Bearer <key>` with the complete key: no quotes, no other scheme such as `Token`, nothing cut off.
- The environment variable is set in the process that makes the call. The SDKs don't read `PUSHQ_API_KEY` for you.
- The key belongs to the server you're calling. A hosted key doesn't work on your own server, and the reverse. Check the SDK's base URL.
- The key hasn't been revoked.

**Fix:** create a new key if needed and pass it explicitly. See [use an API key](https://pushqueue.dev/docs/guides/api-keys/#use-a-key).

### 403 permission_denied: writer key can't list or delete queues

**Symptom:** listing queues (`GET /v1/queues`) or deleting one fails with `403 permission_denied`: `the writer role is not allowed to do this`. Other calls with the same key work.

**Cause:** writer keys work only with queues they know by name. They can't list or delete queues, read `/metrics` when it isn't public, or manage keys and members.

**Fix:** keep the writer key for app code and use an admin key for tooling that lists or deletes queues. See [API key roles](https://pushqueue.dev/docs/guides/api-keys/#key-roles).

### 401 on /v1/me or /v1/teams: session-only endpoints

**Symptom:** `401 unauthenticated` with `sign in to the dashboard to manage your account`, even with a valid admin key.

**Cause:** `/v1/me`, `/v1/me/password` and `/v1/teams` act on a signed-in person, so they need a dashboard session; API keys can't call them.

**Fix:** use the dashboard or console for these. Admin API keys can still manage API keys, members and invites. See the [API reference](https://pushqueue.dev/docs/reference/api/).

### 403 browser requests must send the X-Requested-With header

**Symptom:** `403 permission_denied` with `browser requests must send the X-Requested-With header` on a POST, PUT, PATCH or DELETE.

**Cause:** the request relied on the dashboard session cookie without an `Authorization` header. pushq requires `X-Requested-With` on such requests to block cross-site request forgery.

**Fix:** call the API from your backend with an API key. pushq serves no CORS headers, so calling it from browser code on another site doesn't work anyway.

## 404, 409 and 400 errors

### 404 not_found for a queue name with a slash

**Symptom:** a queue in a folder, such as `user/instagram`, returns `404 not_found` with `no such endpoint; if the queue name contains '/', URL-encode it in the path`.

**Cause:** the name must travel as one URL segment, `user%2Finstagram`. Either the request didn't encode it, or a reverse proxy decoded `%2F` back into `/` before it reached pushq.

**Fix:** with curl or your own HTTP client, encode the name (`/v1/queues/user%2Finstagram/tasks`). The SDKs encode it for you, so if an SDK call still gets this 404 on a self-hosted server, fix the proxy: with nginx, write `proxy_pass http://127.0.0.1:8080;` with no URI part. See [queue names in URLs](https://pushqueue.dev/docs/reference/api/#url-encode-queue-names) and [forward the path unmodified](https://pushqueue.dev/docs/self-hosting/deploy/#forward-encoded-queue-names-unmodified).

### 404 not_found: queue not found

**Symptom:** `404 not_found` with `queue "emails": not found` when you enqueue or read.

**Cause:** the queue doesn't exist on this server or, on the hosted service, in the team the key belongs to. Enqueuing never creates a queue.

**Fix:** create the queue first (an idempotent PUT at deploy time works well), and check the base URL and key. See [create a queue](https://pushqueue.dev/docs/concepts/queues/#create-a-queue).

### 400 invalid_argument: queue name must be...

**Symptom:** creating a queue fails with `400 invalid_argument` and `queue name must be 1-200 chars of '/'-separated segments...`.

**Cause:** queue names are lowercase letters, digits and hyphens, in segments separated by `/`. Uppercase letters, underscores and dots are rejected.

**Fix:** use a name like `emails` or `user/instagram`. See [queue names](https://pushqueue.dev/docs/concepts/queues/#queue-name-rules).

### 409 already_exists when creating a task

**Symptom:** creating a task fails with `409 already_exists`.

**Cause:** a task with that `task_id` already exists in the queue, or finished recently and its ID is still reserved (by default 24 hours after success, 7 days after failure, 1 hour after deletion).

**Fix:** if you set the ID to deduplicate, this is success: the task is already enqueued, so catch the code and carry on. If you meant to run the work again, use a new ID (for example with a version or date suffix). For queues, `POST /v1/queues` returns the same code when the queue exists; use PUT to create or update. See [task IDs and deduplication](https://pushqueue.dev/docs/concepts/tasks/#task-ids-and-deduplication) and the [deduplication pattern](https://pushqueue.dev/docs/patterns/deduplication/).

### :run returns 404 for a finished task

**Symptom:** `POST .../tasks/{task_id}:run` returns `404 not_found` for a task you can still see, or `400 failed_precondition`.

**Cause:** `:run` works only on pending tasks. Succeeded and failed tasks return `404` (Cloud Tasks parity). A task currently being delivered returns `400 failed_precondition`, and so does any task on a disabled queue.

**Fix:** to redo a finished task, create a new task with the same request and a new `task_id`; read the original with `view=full` to get its body and headers. See [run a task now](https://pushqueue.dev/docs/concepts/tasks/#run-a-task-now) and [replay dead letters](https://pushqueue.dev/docs/patterns/replay-dead-letters/).

## Webhook signature verification fails

### Signature verification fails because the body was parsed

**Symptom:** the verifier reports `no matching signature` for every delivery, though the secret is right.

**Cause:** the signature covers the exact bytes pushq sent. If your framework parsed the JSON and you re-serialized it, key order, spacing or number formatting changed.

**Fix:** verify the raw body before parsing: `express.raw()` instead of `express.json()` on that route, `await request.body()` in FastAPI, `io.ReadAll(r.Body)` in Go, `@RequestBody byte[]` in Spring, and no `[FromBody]` model in ASP.NET Core. See [verify signatures](https://pushqueue.dev/docs/getting-started/sdks/#verify-signatures).

### Signature verification fails with the wrong signing secret

**Symptom:** `no matching signature`, with the raw body.

**Cause:** the secret in your handler isn't the one on the queue that delivered the request. Common cases: a different environment's secret; the queue's secret was changed (deliveries are signed when sent, so retries of old tasks use the new secret); or a task delivered from a dead-letter queue, which is signed with the dead-letter queue's own secret.

**Fix:** use the exact string you set as `target.signing_secret` on that queue, including the `whsec_` prefix. Accept both secrets during a rotation, or give related queues the same secret.

### "timestamp outside tolerance": clock skew

**Symptom:** the verifier reports `timestamp outside tolerance`.

**Cause:** `webhook-timestamp` is set when the delivery starts, and the verifier rejects timestamps further from your server's clock than the tolerance, in either direction. The usual tolerance is 300 seconds (5 minutes): the default in TypeScript, Python and .NET, and the value the Go and Java examples pass. Your server's clock is off, or you're verifying a stored request long after it arrived.

**Fix:** sync the clock with NTP. Verify when the request arrives, not later. Raise the tolerance only if you have to. In TypeScript, Python, Go and .NET a tolerance of `0` turns the timestamp check off, which also turns off replay protection.

### Missing webhook-id, webhook-timestamp or webhook-signature headers

**Symptom:** the verifier reports missing `webhook-*` headers.

**Cause:** the queue has no signing secret (`has_signing_secret: false`), so pushq sends unsigned requests. A PUT that sent `signing_secret: ""` clears it.

**Fix:** set `target.signing_secret` on the queue. Omitting `signing_secret` in a later PUT keeps it.

### Every delivery fails with error_kind config: invalid whsec_ secret

**Symptom:** deliveries never reach your endpoint; every attempt has `error_kind: config` and `sign request: invalid whsec_ secret`. Or your verifier throws a base64 error instead of a verification error.

**Cause:** a secret that starts with `whsec_` must be valid base64 after the prefix. The server accepts an invalid one when you save it, then can't sign with it. On the receiving side the SDKs reject it too: Python raises `binascii.Error`, .NET throws `ArgumentException`, Java throws `WebhookVerificationException`, and Go returns an error wrapping `ErrVerification`.

**Fix:** generate a valid secret, for example `echo "whsec_$(openssl rand -base64 32)"`, and set it on the queue and in your handler. The failing tasks keep retrying, so they go through once the secret is fixed.

## Retries and timeouts

### Tasks retried for days: max_attempts defaults to 100

**Symptom:** a failing task keeps being retried, about once an hour, long after you expected it to give up.

**Cause:** the default retry config allows 100 attempts with a backoff capped at one hour, so a task that never succeeds retries for about 3.5 days. With `max_attempts: -1` and no `max_retry_duration_seconds`, it retries forever.

**Fix:** set `retry.max_attempts` (and a [dead-letter queue](https://pushqueue.dev/docs/concepts/dead-letter-queues/)) on the queue, or per task. To stop one task now, delete it. See [retries and backoff](https://pushqueue.dev/docs/concepts/retries/) and [stop retrying](https://pushqueue.dev/docs/patterns/stop-retrying/).

### Task keeps retrying after max_retry_duration_seconds

**Symptom:** you set `max_retry_duration_seconds: 3600`, but the task still retries hours later.

**Cause:** when both `max_attempts` and `max_retry_duration_seconds` are set, retries stop only when **both** limits are reached (Cloud Tasks parity). `max_attempts` defaults to 100, so it is always set unless you change it.

**Fix:** to make the duration the only limit, also set `max_attempts: -1`. See [when retries stop](https://pushqueue.dev/docs/concepts/retries/#what-happens-when-retries-run-out).

### A 400 or 404 from my endpoint is retried

**Symptom:** your handler returns `400` or `404` for a bad task and pushq keeps retrying it.

**Cause:** pushq treats every non-2xx status as a failure and retries it, 4xx included.

**Fix:** when a task can never succeed, log it and return a 2xx. See [what counts as a failure](https://pushqueue.dev/docs/concepts/retries/#what-counts-as-a-failed-delivery).

### Deliveries time out: dispatch_deadline_seconds

**Symptom:** attempts fail with `error_kind: timeout` and a `duration_ms` close to the task's `dispatch_deadline_seconds`. Your handler may still have finished the work, and then runs it again on the retry.

**Cause:** pushq waits up to `dispatch_deadline_seconds` (default 600, range 15 to 1800) for a response. A slower handler times out. A load balancer or proxy in front of your handler may also cut the request off sooner and answer `502` or `504`, which shows up as `non_2xx`.

**Fix:** set `dispatch_deadline_seconds` above your handler's worst case, raise the proxy timeout to match, or acknowledge quickly and do the slow work elsewhere. Make the handler idempotent either way. See [dispatch deadline](https://pushqueue.dev/docs/concepts/tasks/#dispatch-deadline-request-timeout), [long-running work](https://pushqueue.dev/docs/patterns/long-running-work/) and [idempotent handlers](https://pushqueue.dev/docs/patterns/idempotent-handlers/).

## Queue configuration problems

### Upsert wiped my target base_url, headers or dead-letter queue

**Symptom:** after a `PUT /v1/queues/{queue}` (`upsertQueue`), the queue lost its `target.base_url`, `target.headers` or `dead_letter_queue`, or its rate limits went back to defaults.

**Cause:** PUT is a full replace. Every field you leave out is reset to its default. Only `signing_secret` is kept when omitted, and the run state never changes.

**Fix:** send the queue's complete config with every PUT, or change single fields with PATCH. In the Go SDK, `PatchQueue` can't clear string fields (empty strings aren't sent), so use a full `UpsertQueue` to remove a base URL or dead-letter queue. See [create or update a queue with PUT](https://pushqueue.dev/docs/concepts/queues/#create-or-update-a-queue-with-put-upsert) and [update part of a queue](https://pushqueue.dev/docs/concepts/queues/#update-queue-settings-with-patch).

### Failed tasks don't show up in the dead-letter queue

**Symptom:** tasks end as `failed` but nothing appears in the queue named in `dead_letter_queue`.

**Cause:** the dead-letter queue doesn't exist. pushq checks the name's format, not that the queue exists; when the copy fails it only logs `dead-letter failed`. Tasks are also copied only after their retries run out, which with the defaults takes days.

**Fix:** create the dead-letter queue. The copy keeps the original task's `path`, so if tasks use relative paths, give the dead-letter queue its own `target.base_url` too; otherwise its deliveries fail with `error_kind: config`. See [dead-letter queues](https://pushqueue.dev/docs/concepts/dead-letter-queues/).

## Request size and batch errors

### 413 payload_too_large

**Symptom:** a request fails with `413 payload_too_large` (`request body too large`).

**Cause:** the request body is bigger than the server reads. With default settings that is about 2 MiB for a single task create (twice `max_body_bytes`, to allow for base64, plus 64 KiB), 8 MiB for a batch, and 256 KiB for a queue config. A task body that fits the request but is over 1 MiB once decoded is rejected separately, with `400 invalid_argument` and `body exceeds 1048576 bytes`.

**Fix:** keep task bodies under 1 MiB. Store large payloads elsewhere and send a reference, and split big batches. On a self-hosted server, also check the reverse proxy's body limit (nginx defaults to 1 MB; set `client_max_body_size`). See [task limits](https://pushqueue.dev/docs/concepts/tasks/#task-size-and-scheduling-limits).

### Batch enqueue returns 200 but some tasks failed

**Symptom:** `POST .../tasks:batch` succeeds, but some tasks don't exist.

**Cause:** a batch reports per-item results. The request returns `200` as long as the batch itself is valid; each item has either a `task` or an `error` with its own `code` (`already_exists`, `invalid_argument`, `failed_precondition`, ...). Only a malformed request (invalid JSON, an empty batch, more than 500 tasks), a missing queue or an oversized body fails the whole request.

**Fix:** check every result's `error`. Treat `already_exists` as success, fix and resend the `invalid_argument` items. See [batch enqueue](https://pushqueue.dev/docs/concepts/tasks/#batch-enqueue-up-to-500-tasks) and [bulk enqueue](https://pushqueue.dev/docs/patterns/bulk-enqueue/).

### SDK error with code internal and an HTML detail

**Symptom:** an SDK error has code `internal` and a detail that looks like an HTML page.

**Cause:** the response didn't come from pushq. A proxy, load balancer or wrong base URL returned its own error page, and the SDK wraps it as `internal`.

**Fix:** check the base URL and the status code, then the proxy's logs.

## Self-hosted server problems

### Dashboard says setup required

**Symptom:** the dashboard asks you to create an admin account, and the server logs `the API is UNAUTHENTICATED`.

**Cause:** no dashboard account exists yet. Until one does, a server without `api_keys` in its config accepts every request without credentials. If the config has `api_keys`, the API is already protected and setup asks for one of its admin keys.

**Fix:** create the admin account right away, before exposing the server. If you're locked out of an existing install, use `pushq users reset-password`. See [create the first admin account](https://pushqueue.dev/docs/self-hosting/install/#create-the-first-admin-account) and [locked out](https://pushqueue.dev/docs/self-hosting/install/#recover-a-locked-out-admin-account).

### Session cookie isn't Secure behind a reverse proxy

**Symptom:** the `pushq_session` cookie lacks the `Secure` flag even though the dashboard is served over HTTPS.

**Cause:** TLS ends at your proxy, so pushq sees plain HTTP. It marks the cookie `Secure` only when the request arrived over TLS or carries `X-Forwarded-Proto: https`.

**Fix:** have the proxy send `X-Forwarded-Proto` (nginx: `proxy_set_header X-Forwarded-Proto $scheme;`; Caddy sets it by default). See [tell pushq the request was HTTPS](https://pushqueue.dev/docs/self-hosting/deploy/#set-x-forwarded-proto-for-tls).

## Read more

- [Going to production](https://pushqueue.dev/docs/guides/going-to-production/): the checklist that prevents most of these problems.
- [Errors reference](https://pushqueue.dev/docs/reference/errors/): every error code and HTTP status.
- [Retries and backoff](https://pushqueue.dev/docs/concepts/retries/): what counts as a failure and when retries stop.
- [Delivery](https://pushqueue.dev/docs/concepts/delivery/): the request pushq sends and its headers.
- [Self-hosting operations](https://pushqueue.dev/docs/self-hosting/operations/): health checks, metrics and logs.
