---
title: "Scan failures"
description: "Why a scan was refused, never started, timed out, or failed outright, and what to change in each case."
---

A scan can go wrong in four places: the request can be refused, the work can
sit queued, the work can run and time out, or the work can run and be refused
on the way to being recorded. The symptoms are different enough to tell apart.

Start by reading the scan itself:

```bash
curl -s localhost:8080/api/v1/scans/$SCAN_ID \
  -H "Authorization: Bearer $TRUSTIVAN_KEY"
```

`status` is one of `queued`, `running`, `succeeded`, `failed` or `canceled`.
The last three are terminal. A failed scan carries an error message saying what
happened, and `database_state` is present on every completed scan of an image,
repository, filesystem or SBOM.

A scan you no longer want can be stopped with `POST /scans/{id}/cancel`. A
running scan stays `running` until the worker has stopped it, then becomes
`canceled`.

## A dynamic scan was passive when I expected an active one

**Symptom.** The scan succeeded with a warning that starts "Passive checks
only", and found only header, cookie and TLS issues.

**Cause.** Ownership is checked again when each scan runs. If the warning says
ownership "is not verified", the DNS record and the file both answered without the
token, so the target was marked unverified. If it says ownership "could not be
re-checked just now", the check got no answer, and only that scan was passive.

**Fix.** Open the target under **DAST**. It shows the reason the last check
failed. If the target is unverified, publish the token again and choose **Check
now**; see [Add and verify a DAST target](/how-to/add-and-verify-a-dast-target). If
it is still verified, there is nothing to do: the next scan checks again.

## A dynamic scan is queued for a long time or cannot start

**Symptom.** The scan stays **Queued**, or adding a target or starting a scan
answers `503` `dast_engine_unavailable`, or a queued scan fails with "the dynamic
scan engine is not reachable".

**Cause.** A deployment has one engine and it runs one scan at a time, so a scan
stays queued while another runs, and spends nothing while it does. A `503` or that
failure means the engine is off or down, and the message says which: it can be
that the `zap` or `dast-egress` service is down, or that it was down when the API
or worker started.

**Fix.** On a self-hosted deployment, see
[Dynamic scanning configuration](/configuration/dynamic-scanning): start both
services, and if the message asks for it, restart the API and worker. Nothing
queues up for the engine to return, so run the scan again afterwards. The DAST page
shows the same message as the refusal.

## A dynamic scan stopped at its time limit

**Symptom.** The scan succeeded with the warning "The scan reached its time
limit" and fewer findings than you expected.

**Fix.** Raise the target's time limit (up to 60 minutes), or add separate
targets for parts of the application. An incomplete scan never closes
findings. See [Limits](/concepts/dynamic-scanning-limits).

## The image reference was rejected

**Symptom.** `POST /scans` returns `400` immediately, with a message naming a
rule. Nothing is queued and no scan row exists.

This is not a parser being fussy. The reference you supply becomes an outbound
network request made by TRUSTIVAN on your behalf, so validation is a security
boundary. See [Security model](/security/model). Every rule below refuses
a specific abuse:

| Your reference looks like | Rejected because |
|---|---|
| `169.254.169.254/x:latest` | Link-local. On AWS, GCP and Azure that address serves instance credentials to anything that asks |
| `10.0.0.5:5000/app:1`, `192.168.1.10/app:1`, `localhost:5000/app:1` | A private or loopback registry. Permitted only by deployment setting. See below |
| `user:password@registry/app:1` | Embedded credentials. A reference reaches a database row, a job payload, a log line and an API response; a secret must not ride along inside one |
| `https://registry/app:1`, `docker://app:1` | A URL scheme is not part of an image reference |
| `registry/../../etc/passwd:1` | A path traversal segment, which must never reach a registry client or a cache path |
| `-app:1`, or a reference containing a space, tab, newline or NUL | Argument splitting, log injection, and a reference read as a command-line flag |
| Anything over 512 characters | Length limit, applied before any parsing |
| `Registry/MyApp:1` | Uppercase in a repository path. Rejected rather than folded, because folding would collapse two references a registry treats as distinct into one asset |
| `app@sha256:abc` (short or non-hex digest) | A malformed digest. Only full-length SHA-256 and SHA-512 digests are accepted |

Component limits also apply: at most 12 path components, each at most 128
characters.

**Fix.** Use a fully-qualified public reference: `ghcr.io/org/app:1.2.3`,
`alpine:3.19`. A short name is expanded for you: `alpine` becomes
`index.docker.io/library/alpine:latest`, and an untagged reference means
`latest` explicitly so that `alpine` and `alpine:latest` are the same asset
rather than two.

## The registry is unreachable, or the image does not exist

**Symptom.** The scan is accepted with `202`, moves to `running`, then fails
with an error mentioning the registry, a manifest, or an authorisation
challenge from the registry.

TRUSTIVAN does not distinguish these for you, because the registry does not
always distinguish them either: many registries return the same response for
"this repository does not exist" and "you may not see this repository".

Check, in order:

1. **The reference is exactly right**, including the tag. A typo in a tag is by
   far the most common cause.
2. **The worker has egress to that registry.** The worker, not the API, makes
   the pull. In a Compose deployment they are separate containers, so proving
   the API can reach a host proves nothing about the worker.
3. **The registry is not rate-limiting you.** Docker Hub in particular applies
   anonymous pull limits per source address, and a shared CI egress address
   reaches them quickly. The error usually says so.
4. **The image is genuinely public.**

If the scan failed at once, without retrying, and says the target "resolved, or
was redirected, to a private, loopback or link-local address", the worker
refused the connection. The name was accepted, but when the scan connected it
resolved to one of those addresses, or the registry redirected there. For an
internal registry, name it in `SCAN_ALLOWED_REGISTRIES`. If its token service
or blob storage is on a different host, name that host too. See
[Scanning](/configuration/scanning). Link-local addresses are never
permitted. For a repository, the setting is `SCAN_ALLOW_PRIVATE_GIT_HOSTS`.

Registry and git connections made for a scan ignore `HTTP_PROXY` and
`HTTPS_PROXY`, so a worker whose only egress is a proxy cannot fetch scan
targets.

## The registry requires authentication

Store a credential for that registry host. On Pro and Enterprise,
`POST /api/v1/registry-credentials` accepts either a username with a password
or personal access token, or a bearer token, against a registry host; scans of
images from that host then present it. Creating one requires an administrator
and a human principal: `credentials:manage` is not grantable to an API key.

Three consequences worth knowing before you debug one:

- **The secret cannot be read back**, by anyone, at any role. If you have lost
  it, rotate it with `PUT /api/v1/registry-credentials/{id}/secret`.
- **A credential that cannot be resolved fails the scan** rather than falling
  back to an anonymous pull, which could otherwise pull a public image of the
  same name and report its findings as yours.
- **Only a registry that actively rejected the credential marks it invalid.** A
  timeout leaves the status untouched, so a network blip does not stop your
  scanning for a reason nobody can find.

A recurring source of confusion is worth naming directly:
`SCAN_ALLOW_PRIVATE_REGISTRIES` is about **network reachability, not
authentication**. It permits registry hosts that are, or resolve to, loopback
or private addresses: an on-premises deployment scanning an internal registry
on `10.0.0.5:5000`. Link-local addresses stay refused even with it on. It does not supply credentials to
anything. An internal registry that requires a login still fails with it
enabled.

It is also a **deployment** setting, not a per-scan option, because the caller
supplying the reference is the untrusted party. Enabling it makes TRUSTIVAN
willing to reach private address space, so treat it as a deliberate operator
decision.

If private registry support is what you need, see the
[FAQ](/faq/general) for the current position and [Contact](https://trustivan.com/contact/).

## The scan is stuck in `queued`

**Symptom.** `status` stays `queued` and never becomes `running`.

Work in `queued` is **never dropped**. There is no timeout on queueing, and no
path that silently discards a scan, so this state means something is not
consuming, not that something was lost.

Two causes, in order of likelihood:

**The worker is not running.** The API and the worker are separate processes on
purpose, and the API happily accepts scans without one. Check that the worker
container is up and look at its logs:

```bash
docker compose ps
docker compose logs scan-worker --tail 50
```

A worker that starts and immediately exits is usually failing on
configuration: most often a missing `TOKEN_ENCRYPTION_KEY`, or a vulnerability
database provider set to `mirror` with no repositories configured, which is a
startup error rather than a silent fallback to the public source.

**Per-tenant concurrency is saturated.** Your plan sets how many of your scans
run at once (**1** on Free, **5** on Pro, **20** on Enterprise), and the
deployment's workers set how many run at all (`SCAN_CONCURRENCY` × worker
replicas; two on the default install). Queue fifty on Pro and at least
forty-five wait.

That is a fairness limit rather than a capacity one, and the queued work is
safe: it will be picked up as running scans complete. If your scans take a
minute each and you queue them in a burst, the tail of the burst waits several
minutes, which looks like a hang and is not one. Watch the queue drain before
adding workers or changing plan.

## The scan timed out

**Symptom.** `status` is `failed`, with an error about a timeout, after roughly
ten minutes.

`SCAN_TIMEOUT_MINUTES` defaults to **10**. That covers pulling, unpacking and
analysing an ordinary image comfortably. It is exceeded by:

- A genuinely very large image: multi-gigabyte images with many layers.
- A slow or rate-limited registry, where most of the time is spent waiting for
  bytes rather than analysing them.
- A **cold vulnerability database**, on the very first scan after a deployment
  with no persistent cache. The initial download is around 50 MB and dominates
  the first run.

That last one is worth checking before raising the limit, because it has a
better fix. The scanner cache directory must be a **persistent volume**. Without
one, every worker restart re-downloads the database, which is the difference
between a scan taking seconds and taking minutes, and it will time out again
tomorrow. See [Scanning
configuration](/configuration/scanning).

## The scan failed because the database is too old

**Symptom.** `status` is `failed`, with a message saying the vulnerability
database is some number of days old, beyond the limit, and that scanning was
refused because a clean result would be misleading.

**This is working correctly.** It is the single deliberate hard failure in the
scanning path.

A scanner matching against a database that predates the advisories it was
supposed to find succeeds, exits cleanly, and reports nothing. A stale
scanner's silence is indistinguishable from good news, and the user sees a
green result with a recent timestamp, with nothing in either to suggest the
answer is wrong. Every other failure in TRUSTIVAN announces itself; this one has
to be made to.

There are two thresholds:

| Setting | Default | At this age |
|---|---|---|
| `VULN_DB_MAX_AGE_HOURS` | 48 (2 days) | The scan runs, records a warning, and reports `database_state: "stale"` |
| `VULN_DB_HARD_MAX_AGE_HOURS` | 336 (14 days) | The scan **fails**. Nothing is persisted |

Degrade first, fail closed second. A database two days old is missing a handful
of advisories and is still far more useful than no scan; a database two weeks
old will confidently report a clean image that has known criticals.

**To fix it, restore the database rather than raising the threshold.** In order:

1. **Check the worker's egress.** The upstream database rebuilds several times
   a day, so a deployment with working connectivity is never near the soft
   threshold, let alone the hard one. Reaching it means something is wrong:
   blocked egress to `ghcr.io` or `mirror.gcr.io`, a proxy that intercepts OCI
   pulls, or a firewall change nobody connected to this.
2. **Check the cache directory is actually persisted**, and that the worker can
   write to it. A cache that is not persisted is not the cause of staleness on
   its own, but a cache the worker cannot write to means the refreshed copy is
   never kept.
3. **If you run a mirror**, check the mirror itself is being refreshed. A stale
   mirror is the most common cause of this failure in an on-premises
   deployment, because everything else looks healthy.
4. **Restart the worker** once egress is restored, to force a refresh, and
   re-run the scan.

Raising `VULN_DB_HARD_MAX_AGE_HOURS` does not make the results better. It makes
a wrong answer reportable. The only reason to raise it is a deliberate,
temporary decision by someone who knows the data is old and wants degraded
results anyway, and the warning on every scan is then the record of that
decision. See [Vulnerability
database](/configuration/vulnerability-database).

## Reading `database_state`

Every completed scan carries `database_state`, reporting how fresh the advisory
data behind the result was:

| Value | Meaning | What to do |
|---|---|---|
| `fresh` | Within the configured age. The result is authoritative | Nothing |
| `stale` | Older than `VULN_DB_MAX_AGE_HOURS`. The scan ran and the result is recorded, with a warning | Investigate connectivity. Treat a clean result as provisional |
| `unusable` | Beyond the hard limit | The scan failed. See above |
| `unknown` | The database reported no build time, so freshness could not be verified | Expected on a brand-new deployment's first scan. Persistent `unknown` is worth investigating |

`unknown` is treated as usable rather than refused, because a first scan on a
fresh deployment legitimately has no timestamp yet and refusing it would make
every new install look broken.

**If you are gating a pipeline, branch on this field.** A build that treats
`stale` the same as `fresh` has quietly opted out of the guarantee the hard
limit exists to provide. The honest reading is: a clean result with
`database_state` other than `fresh` is not evidence of a clean image.

## Where to go next

- [Assets and scans](/concepts/assets-and-scans): what the objects mean.
- [Scanning configuration](/configuration/scanning): the settings named
  above.
- [Authentication errors](/troubleshooting/authentication): if the
  request never got as far as being a scan.
