Labelgate

Common Issues

Find your error message or symptom and fix it.

Search this page for the start of your error message. Most messages already name the setting to change and how.

First steps

  1. Read the log. If Labelgate does not start, the reason is printed as labelgate: .... Problems found while it runs are logged as msg="reconcile problem".

    docker compose logs --tail 100 labelgate
    docker compose logs labelgate | grep -E "WARN|ERROR"

    A problem is logged when it appears or its cause changes, again every hour while it lasts (still_present=true), and once when it is fixed (reconcile problem resolved). So an old log line may no longer apply.

  2. Open the dashboard at http://localhost:28111/dashboard/.

    • Overview → Sync problems lists every current problem (up to 200) with a count. The panel is hidden when there are none. The API returns the same list in sync.problems and the count in sync.problems_total of GET /api/overview.
    • DNS, Tunnels and Access list every resource. Open one in status error to see why.
    • Agents shows which agents are connected.
  3. Turn on debug logs if you need more detail, then restart:

    LABELGATE_LOG_LEVEL=debug   # or log_level: debug in labelgate.yaml

Labelgate reads its configuration only at startup. After a change, run docker compose up -d (environment) or docker compose restart labelgate (config file). Label and Cloudflare problems are retried on every sync (every 5 minutes, sync.interval) and whenever a container changes.

Startup and configuration

labelgate: config: ...

Labelgate exits (or keeps restarting) right after start:

labelgate: config: 3 problems:
  sync.remove_dely: unknown key; did you mean sync.remove_delay?
  api.token (env LABELGATE_API_TOKEN): must be at least 16 characters, got 5 (generate one with: openssl rand -hex 32)
  cloudflare.api_token (env LABELGATE_CLOUDFLARE_API_TOKEN): no Cloudflare API token is configured: set this, or add an entry under cloudflare.credentials in the config file

Cause: a setting is missing, misspelled or invalid. Each line names one key and the environment variable that sets it. All problems are listed at once, including values of the wrong type.

Fix:

  1. Fix each key, in labelgate.yaml or with the variable shown in (env ...). Keys without (env ...) can only be set in the config file.
  2. unknown key; did you mean ...?: rename the key as suggested. Without a suggestion, compare it with the configuration reference or delete it.
  3. removed in v0.3: delete the key. See Removed keys.
  4. Start again: docker compose up -d.

config: cannot open the config file

labelgate: config: cannot open the config file set by LABELGATE_CONFIG: stat /etc/labelgate/labelgate.yaml: no such file or directory; fix the path or mount the file into the container

Cause: LABELGATE_CONFIG (or --config) points to a file that is not in the container.

Fix: mount the file. Labelgate finds /etc/labelgate/labelgate.yaml without LABELGATE_CONFIG.

services:
  labelgate:
    volumes:
      - ./labelgate.yaml:/etc/labelgate/labelgate.yaml:ro

Related messages:

  • config: cannot parse ...; fix the syntax at the reported position: a YAML syntax error. Fix the line the message names.
  • config: cannot check for a config file: ...; make it readable by the labelgate user or pass --config: Labelgate runs as UID 65532. Run sudo chown 65532 labelgate.yaml.

open store "/app/config/labelgate.db"

labelgate: open store "/app/config/labelgate.db": ...; labelgate cannot write the database: make its directory writable by the labelgate user (the image runs as UID 65532: sudo chown -R 65532:65532 <host data dir>), or change db.path (env LABELGATE_DB_PATH)

Cause: the data folder belongs to another user. Labelgate runs as UID 65532.

Fix:

  • Bind mount (./labelgate-data:/app/config):

    sudo chown -R 65532:65532 ./labelgate-data
  • Named volume made by an older image: find its name with docker volume ls, then:

    docker run --rm -v VOLUME_NAME:/data alpine chown -R 65532:65532 /data

If the message ends with this database was written by a newer labelgate, you started an older version. Run the newer version again, or restore the v0.2 backup.

api: cannot listen on :28111

api: cannot listen on :28111: listen tcp :28111: bind: address already in use; free the port or change api.address (env LABELGATE_API_ADDRESS)

Cause: another program already uses the port. This usually happens with network_mode: host.

Fix: stop the other program, or move Labelgate to another port and update ports: to match.

LABELGATE_API_ADDRESS=:28121

The same applies to agent: cannot listen on ...: change agent.listen (LABELGATE_AGENT_LISTEN) on the main, or connect.listen (LABELGATE_CONNECT_LISTEN) on an inbound agent.

Docker

Cannot connect to the Docker daemon

docker: cannot list containers: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?; no Docker daemon answers at unix:///var/run/docker.sock: mount the socket into the container (volume /var/run/docker.sock:/var/run/docker.sock:ro) or set docker.endpoint (env LABELGATE_DOCKER_ENDPOINT); resources of local containers are kept unchanged until Docker answers again

Cause: the Docker socket is not mounted into the container.

Fix: mount it. For rootless Docker, mount your user's socket (for example /run/user/1000/docker.sock) at the same container path.

services:
  labelgate:
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

Nothing is deleted while Docker does not answer.

permission denied on the Docker socket

docker: cannot list containers: permission denied ...; labelgate may not open the Docker socket: add the socket's group ID to the container (compose group_add; find it with: stat -c %g /var/run/docker.sock)

Cause: Labelgate runs as UID 65532, which is not in the group that owns the socket.

Fix:

  1. Find the group ID: stat -c '%g' /var/run/docker.sock

  2. Add it to the service and run docker compose up -d:

    services:
      labelgate:
        group_add:
          - "988"   # the number from step 1

Remote Docker over tcp://

The message starts with docker: cannot list containers:. Find its ending in the table:

Message ends withFix
the Docker daemon's TLS certificate is not trustedSet docker.tls.ca (LABELGATE_DOCKER_TLS_CA) to the CA file that signed the daemon's certificate.
the Docker daemon requires a client certificateSet docker.tls.cert (LABELGATE_DOCKER_TLS_CERT) and docker.tls.key (LABELGATE_DOCKER_TLS_KEY).
the Docker daemon expects TLSSet docker.tls.ca, and the client certificate if the daemon asks for one.
check docker.endpoint (env LABELGATE_DOCKER_ENDPOINT) and that the Docker daemon listens thereFix the host and port in LABELGATE_DOCKER_ENDPOINT.

Mount the certificate files into the container, for example ./docker-certs:/certs:ro.

Cloudflare

cloudflare credential validation failed

Labelgate exits at start:

labelgate: cloudflare credential validation failed; to skip this startup check set skip_credential_validation (env LABELGATE_SKIP_CREDENTIAL_VALIDATION) to true: credential "default": cloudflare tokens.verify: HTTP 401 ...; replace the API token in cloudflare.api_token (env LABELGATE_CLOUDFLARE_API_TOKEN): Cloudflare reports it as invalid, expired or revoked; create a new one under My Profile > API Tokens in the Cloudflare dashboard

Cause: Cloudflare does not accept the token, or a configured tunnel does not exist.

Fix: find the end of the message:

  • replace the API token in ... or is disabled or expired: create a new token and put it in the key the message names.
  • is invalid and Cloudflare temporarily blocks it: see Token locked out.
  • wait a moment, then start labelgate again: Cloudflare was busy (HTTP 429 or 5xx). Wait a moment, then run docker compose up -d.
  • no such tunnel in account: compare LABELGATE_CLOUDFLARE_TUNNEL_ID and LABELGATE_CLOUDFLARE_ACCOUNT_ID with Zero Trust > Networks > Tunnels.
  • cannot reach the Cloudflare API: see below.

was refused: give it the ... permission

cannot create DNS record: cloudflare dns.create: HTTP 403 ...; the API token in cloudflare.api_token (env LABELGATE_CLOUDFLARE_API_TOKEN) was refused: give it the Zone:DNS:Edit permission for this zone or account under My Profile > API Tokens in the Cloudflare dashboard (or replace it if it is invalid)

Cause: the token lacks the permission named in the message, or does not cover this zone or account.

If the message says replace the API token in ... instead, the token itself is invalid, expired or revoked. Create a new one and restart Labelgate.

Fix:

  1. Open My Profile > API Tokens and edit the token.
  2. Add the permission from the message (Zone:Zone:Read, Zone:DNS:Edit, Account:Cloudflare Tunnel:Edit or Access: Apps and Policies:Edit).
  3. Check that Zone Resources include the domain and Account Resources include the account.

No restart is needed. The next sync uses the new permissions.

no matching zone

app.example.com: no matching zone: no configured API token can see a zone containing this hostname (cloudflare.credentials.<name>.zones may also exclude it); add the zone to a token's Zone Resources under My Profile > API Tokens in the Cloudflare dashboard, or fix the hostname

Cause: no API token can see the domain of this hostname.

Fix:

  1. Check the hostname in the label for typos.
  2. Add the domain to the token's Zone Resources.
  3. With several tokens: check the zones list of each credential and the credential label.

A domain you just added is found within a minute.

unknown tunnel or no default tunnel configured

tunnel "media": unknown tunnel: use "default" (the tunnel in cloudflare.tunnel_id, env LABELGATE_CLOUDFLARE_TUNNEL_ID) or a name or tunnel ID from cloudflare.tunnels in the main instance config
no default tunnel configured: name the tunnel in the label, or set cloudflare.tunnel_id (env LABELGATE_CLOUDFLARE_TUNNEL_ID) or default_tunnel (env LABELGATE_DEFAULT_TUNNEL) in the main instance config
credential "corp": unknown credential: add cloudflare.credentials.corp to the main instance config, or use default (cloudflare.api_token) or another configured credential

Cause: a tunnel or credential label names something the main config does not define, or no default tunnel is set.

Fix: set LABELGATE_CLOUDFLARE_TUNNEL_ID for the default tunnel. For more tunnels or tokens, add them to labelgate.yaml (file only) with the name the label uses:

cloudflare:
  tunnels:
    media:
      account_id: "your-account-id"
      tunnel_id: "your-tunnel-id"

cannot reach the Cloudflare API

cloudflare dns.list: dial tcp ...; cannot reach the Cloudflare API: check DNS, outbound HTTPS (port 443) and proxy settings of the labelgate host

Cause: the container has no working internet access.

Fix: check DNS, the firewall and the proxy of the host. Test from the host: curl -I https://api.cloudflare.com.

Cloudflare is rate-limiting this API token

cloudflare dns.list: HTTP 429 ...; Cloudflare is rate-limiting this API token; labelgate retries on the next sync

Cause: too many API calls in a short time, often after restarting many containers at once.

Fix: wait. Labelgate retries on the next sync. At startup the message ends with wait a moment, then start labelgate again: do that. If it keeps happening, sync less often:

LABELGATE_SYNC_INTERVAL=15m
LABELGATE_DOCKER_POLL_INTERVAL=5m

is invalid and Cloudflare temporarily blocks it

cloudflare dns.list: HTTP 429 (codes [10502]) ...; the API token in cloudflare.api_token (env LABELGATE_CLOUDFLARE_API_TOKEN) is invalid and Cloudflare temporarily blocks it after repeated authentication failures; replace the token, then wait for the lockout to expire

Cause: the token is invalid. After repeated failed calls, Cloudflare locks it out for a while.

Fix:

  1. Create a new token and put it in the key the message names.
  2. Wait for the lockout to expire before you start Labelgate again. A restart loop (restart: unless-stopped) keeps the lockout active, so stop the container until then: docker compose stop labelgate.

Labelgate does not retry calls that hit this lockout.

target auto: cannot detect this host's public IPv4 address

target auto: cannot detect this host's public IPv4 address: ...; set the record's target label to an IP address instead
target auto needs the public IPv4 address of agent edge1, which it did not report (it could not detect one); set the record's target label to an IP address instead

The agent itself logs cannot detect this host's public IPv4 address: records with target auto need it; ..., and public IPv4 detection recovered once it works again. IPv6 failures are logged at INFO, not as warnings, because many hosts have no IPv6. They only matter for AAAA records with target: auto.

Cause: target: auto needs the public IP. Labelgate asks api.ipify.org and ipv4.icanhazip.com (IPv6: api6.ipify.org, ipv6.icanhazip.com), and could not reach them. For an agent, the agent host could not reach them.

Fix: allow outbound HTTPS to those hosts, or set the IP yourself:

labels:
  labelgate.dns.web.target: "203.0.113.10"

Hostname gives 502 or error 1033

Cause: the tunnel route exists, but cloudflared is not running or cannot reach your app.

Fix: see cloudflared: common problems.

Conflicts

A conflict never changes anything on Cloudflare. The resource stays in status error until you fix the cause; then the next sync clears it.

conflict: existing record not owned by labelgate

conflict: existing record not owned by labelgate: a CNAME record for app.example.com (id 3f2a...) already exists in Cloudflare; delete it under DNS > Records in the Cloudflare dashboard or use another hostname

Cause: Cloudflare already has a record, Access application or tunnel route for this hostname that Labelgate did not create. Labelgate never takes over or changes those.

Fix: find the rest of the message:

Message continues withFix
a ... record for ... already exists in CloudflareDelete the record under DNS > Records, or use another hostname.
it was created by labelgate instance "a1b2c3d4"If this installation lost its database, set LABELGATE_INSTANCE_ID=a1b2c3d4, but only if that instance is permanently gone. Never while it still runs: both would claim the same records. See If you lose the database.
the ownership marker was removed from the commentPut labelgate:<instance_id> back at the start of the record's comment, or delete the record.
an Access application for ... already existsDelete it under Zero Trust > Access > Applications, or remove the access label.
the tag "labelgate-..." was removedAdd the tag back to the Access application, or delete it.
tunnel ... already routes ... with a rule labelgate did not createRemove the route under Zero Trust > Networks > Tunnels (published application routes).
Cloudflare refused to create ... because a conflicting object already existsDelete the existing object, or use another hostname.

See Ownership & Conflicts.

conflict: the A record ... is already managed by

conflict: the A record app.example.com is already managed by container web service web on the main instance; remove the duplicate label from one of the containers

Cause: two containers claim the same record or route. The one that had it first keeps it.

Fix: remove the label from one container. If you stop or remove the current owner instead, the other container takes over on the next sync.

conflict: hostname ... is already managed by agent

conflict: hostname app.example.com is already managed by agent edge1, and a hostname can belong to only one instance (main or one agent); remove this label or the one on agent edge1

Cause: a hostname belongs to one host: the main or one agent. Another host already has resources for it.

Fix: define every service of that hostname on the same host, or remove the label on the other host. The hostname is free once the other host's resources are deleted (after sync.remove_delay). Resources kept with cleanup: "false" hold the hostname until you delete them in Cloudflare.

conflict: hostname ... already has

conflict: hostname app.example.com already has a route on tunnel 6ff4... from container web service web on the main instance; a hostname can have DNS records, one CNAME record or one tunnel route, not a mix: remove one of the labels

Cause: one hostname has both a DNS label and a tunnel label. A tunnel route creates its own DNS record.

Fix: keep only one. For a tunnel, remove the dns labels:

labels:
  labelgate.tunnel.web.hostname: "app.example.com"
  labelgate.tunnel.web.service: "http://app:80"

conflict: an older labelgate ... record ... still uses this hostname

conflict: an older labelgate CNAME record for app.example.com (id 9b1c...) still uses this hostname (its label set cleanup=false, or sync.remove_delay has not passed); delete it under DNS > Records in the Cloudflare dashboard to use the hostname now

Cause: you changed how the hostname is published, for example from a DNS record to a tunnel. The old record still exists.

Fix: wait for sync.remove_delay (default 30m), or delete the old record under DNS > Records now.

Labels

container ...: label ...

local container web: label labelgate.dns.web.proxied: invalid boolean "maybe" (use true or false)

The resource itself shows:

label error: labelgate.dns.web.proxied: invalid boolean "maybe" (use true or false); the existing Cloudflare objects are kept unchanged until the label is fixed

Cause: a label has a wrong value, a typo in its name, or a required label is missing.

Fix: fix the label named in the message and recreate the container (docker compose up -d). Nothing on Cloudflare changes until then. See When a label is wrong.

access policy "..." is not defined

access policy "team" is not defined: add labelgate.access.team.* labels to this container or another container of the same host

Cause: a service uses access: "team", but no container on that host defines the policy team.

Fix: define it, on this container or another one on the same host:

labels:
  labelgate.access.team.policy.include.emails: "you@example.com"

If the message says is defined differently on several containers of this host, make the definitions identical or keep only one.

A container is ignored, with no error

Check:

  • The container is running. Stopped containers count as gone.
  • Every key starts with labelgate. and has four parts: labelgate.<type>.<name>.<property>. Labels without the prefix are ignored.
  • If docker.filter_label (LABELGATE_DOCKER_FILTER_LABEL) is set, the container carries that label.
  • If you changed label_prefix (LABELGATE_LABEL_PREFIX), the labels use the new prefix.

Agents

cannot connect to the main instance; retrying

The agent logs:

level=WARN msg="cannot connect to the main instance; retrying" url=wss://main.example.com:28112/agent error="...; nothing serves agent connections at that path: connect.endpoint (env LABELGATE_CONNECT_ENDPOINT) must end in /ws"

Fix: find the end of the error:

Error containsFix
must end in /wsUse LABELGATE_CONNECT_ENDPOINT=wss://main.example.com:28112/ws.
this port is not labelgate's agent listenerHTTP 404 on /ws: the URL uses the dashboard port 28111. Use the agent port 28112 (agent.listen).
nothing listens thereStart the main with agent.enabled: true (LABELGATE_AGENT_ENABLED=true), publish "28112:28112", and open the port in the firewall.
does not resolveFix the host name in LABELGATE_CONNECT_ENDPOINT.
TLS certificate is not trustedSet LABELGATE_CONNECT_TLS_CA to your CA file, or use a public certificate.
TLS certificate does not list the hostUse a host name that the certificate is issued for.
does not use TLS: use ws://Use ws://, or give the main a certificate (agent.tls.cert, agent.tls.key).
likely expects TLS: use wss://The main uses TLS. Use wss://.
the reverse proxy in front of the main instance cannot reach itHTTP 502, 503 or 504: your reverse proxy cannot reach the main. Check that the main runs and that the proxy forwards to its port 28112.
does not belong to labelgate's agent portAnother server answered. Check the host, port and path.

When the main dials an inbound agent, the main logs cannot connect to inbound agent; retrying with the same endings. Fix agent.agents.<id>.connect_to and agent.tls.ca on the main instead.

main rejected this agent

The agent logs:

level=WARN msg="handshake with the main instance failed" error="...; main rejected this agent: either agent \"edge1\" is not configured on the main instance (add agent.agents.edge1 with this agent's token there, or set agent.accept_token, env LABELGATE_AGENT_ACCEPT_TOKEN), or the tokens do not match: connect.token (env LABELGATE_CONNECT_TOKEN) on this agent must equal agent.agents.edge1.token (or agent.accept_token) in the main instance config"

The main logs agent handshake failed and names the agent, for example agent "edge1" is not configured: add agent.agents.edge1 with a token to the main instance config.

Failed handshakes are throttled: one warning per address and agent ID every 5 minutes. The next one counts the suppressed attempts (suppressed=...).

Cause: the agent ID or the token does not match the main's config.

Fix:

  1. LABELGATE_CONNECT_AGENT_ID on the agent must equal the key under agent.agents on the main.
  2. LABELGATE_CONNECT_TOKEN must equal that entry's token. Copy it again.
  3. An agent listed under agent.agents must use its own token. agent.accept_token does not work for it.
  4. labelgate.yaml does not expand ${VAR}. Paste the real token.
  5. Restart the main after changing its config.

must be at least 32 characters (agent token)

labelgate: config: connect.token (env LABELGATE_CONNECT_TOKEN): must be at least 32 characters, got 12 (generate one with: openssl rand -hex 32)

Cause: agent tokens need at least 32 characters and 12 different characters. A ${VAR} left unexpanded in labelgate.yaml also fails this check.

Fix: make a new token and put it on both sides (agent.agents.<id>.token on the main, LABELGATE_CONNECT_TOKEN on the agent):

openssl rand -hex 32

another agent with ID "..." is already connected

peer error: duplicate_agent: agent already connected; another agent with ID "edge1" is already connected: give each agent its own connect.agent_id (env LABELGATE_CONNECT_AGENT_ID)

The main logs rejected a second connection for an agent ID that is already connected.

Cause: two hosts use the same agent ID.

Fix: give each host its own LABELGATE_CONNECT_AGENT_ID.

Agent gets a new ID after the container is recreated

Cause: connect.agent_id is not set and the container has no /etc/machine-id. The agent then uses the container's hostname, which changes on every recreate. Labelgate logs a warning at startup when this happens.

Fix: set the ID, or mount the host's machine ID:

services:
  labelgate-agent:
    environment:
      - LABELGATE_CONNECT_AGENT_ID=edge1
    # or:
    volumes:
      - /etc/machine-id:/etc/machine-id:ro

unsupported_version

peer error: unsupported_version: ...; the main instance runs an incompatible labelgate release: run the same release on both

Fix: run the same Labelgate version on the main and all agents. See Upgrading.

does not match the agent's hostnames allow-list

Agent resources that break an allow-list are rejected. The message names the key to change:

agent "edge1": hostname "app.example.com" does not match the agent's hostnames allow-list; add "app.example.com" (or a glob matching it) to agent.agents.edge1.hostnames in the main instance config
agent "edge1": wildcard hostname "*.example.com" is only allowed by an identical entry (...); add "*.example.com" to agent.agents.edge1.hostnames in the main instance config
agent "edge1": tunnel "media" is not in the agent's allowed tunnels; add "media" to agent.agents.edge1.tunnels in the main instance config

Cause: allow-lists live in the main instance's config. Changing the agent does not help.

Fix: add the value to the key the message names, on the main, then restart the main. For agents that log in with agent.accept_token, the message names agent.accept_hostnames or agent.accept_tunnels and its environment variable instead. See Allow-lists.

A message with a CNAME to ... is not allowed means an agent's DNS label points at a tunnel. Use a tunnel label instead.

service host "..." is a host name, which agents may only use if allow-listed

agent "edge1": service host "traefik" is a host name, which agents may only use if allow-listed; add "traefik" to agent.agents.edge1.services in the main instance config (or use the origin's IP address)

Cause: an agent's tunnel service may point to an IP address. A host name such as traefik must be allowed in the main instance's config.

Fix: on the main, add the host name to that agent's services, then restart the main:

agent:
  agents:
    edge1:
      token: "UNCHANGED"
      services: ["traefik"]   # host name, pattern (*.svc.internal), IP or CIDR

For agents that log in with agent.accept_token, use agent.accept_services (LABELGATE_AGENT_ACCEPT_SERVICES=traefik). Or point the label at the container's IP address.

service target is the loopback address 127.0.0.1, which agents may not use unless allow-listed works the same way: add that IP, or a CIDR containing it. Messages that say no allow-list can permit (unix: sockets, bastion, user:pass@ in the URL) cannot be allowed; change the label. See Agent tunnel services.

Added to agent.accept_services, still rejected

Cause: the agent is listed under agent.agents. The agent.accept_* lists never apply to it.

Fix: use agent.agents.<id>.services (and .hostnames, .tunnels). The message always names the right key. See Named agents vs shared token.

too many containers

too many containers: 5000 > 4096; set docker.filter_label (env LABELGATE_DOCKER_FILTER_LABEL) on the agent to report only labelled containers

Cause: the agent host runs more containers than one report may carry. The main keeps the agent's previous containers.

Fix: on the agent, read only containers with a marker label, and add that label to the containers you publish:

LABELGATE_DOCKER_FILTER_LABEL=public=true

Dashboard and API

API and dashboard disabled: api.token is empty

level=WARN msg="API and dashboard disabled: api.token is empty; set api.token (env LABELGATE_API_TOKEN) to a secret of at least 16 characters (generate one with: openssl rand -hex 32). DNS, tunnel and Access sync keep running"

Fix: set the token and pass it to the container:

openssl rand -hex 32   # put the output in .env as LABELGATE_API_TOKEN
services:
  labelgate:
    environment:
      - LABELGATE_API_TOKEN
    ports:
      - "127.0.0.1:28111:28111"

If the log says API and dashboard disabled by api.enabled (env LABELGATE_API_ENABLED)=false, remove that setting.

Dashboard does not open

Check:

  1. The URL ends in /dashboard/: http://localhost:28111/dashboard/.
  2. The port is published (ports: above) and the log has no api: cannot listen on line.
  3. The log has no API and dashboard disabled line.
  4. this binary was built without the dashboard appears only with a self-built binary. Use the official image, or run yarn build in dashboard/ before go build.

Behind a reverse proxy, forward both /dashboard/ and the API path (api.base_path, default /api) to Labelgate unchanged.

That token was rejected / 401 unauthorized

Cause: the token you entered is not api.token. The API answers 401 with {"error":"unauthorized"}.

Fix:

  1. Copy the value of LABELGATE_API_TOKEN from your .env again.

  2. After you change the token, click Forget API token in the top bar and sign in again.

  3. For the API, send the token as a header:

    curl -H "Authorization: Bearer $LABELGATE_API_TOKEN" http://localhost:28111/api/overview

healthcheck failed

docker compose ps shows the container as unhealthy. See why:

docker inspect --format '{{range .State.Health.Log}}{{.Output}}{{end}}' $(docker compose ps -q labelgate)
OutputFix
the API is not answering at http://127.0.0.1:28111/api/healthThe API did not start. Read the log for the reason.
returned HTTP 404, want 200; check api.base_pathAnother program answers on that port. Check api.address and api.base_path (LABELGATE_API_BASE_PATH).

Resources not removed, or removed unexpectedly

cleanup is on by default. Labelgate deletes a container's resources sync.remove_delay (default 30m) after the container stops or is removed.

Resources stay after the container is gone

Look up the resource's status in the dashboard:

StatusMeaningFix
pending_cleanupWaiting for sync.remove_delay.Wait, or shorten it: LABELGATE_SYNC_REMOVE_DELAY=5m.
orphanedThe label set cleanup: "false". Labelgate leaves it on Cloudflare.Delete it in the Cloudflare dashboard.
not listedLabelgate did not create it and never deletes it.Delete it in the Cloudflare dashboard.

Two more cases keep resources:

  • Offline agent: its resources stay for sync.agent_grace (default 24h), then sync.remove_delay.
  • Docker not answering: nothing is deleted until Docker answers again. See Docker.

Resources were deleted unexpectedly

Causes:

  • The container was stopped or removed for longer than sync.remove_delay.
  • You changed a hostname or record type. The old resource is deleted after sync.remove_delay.
  • An agent was offline for longer than sync.agent_grace plus sync.remove_delay.
  • sync.remove_delay is 0s, which deletes at once.

Fix: keep the resources of important services, and give yourself more time:

labels:
  labelgate.dns.web.cleanup: "false"
  labelgate.tunnel.web.cleanup: "false"
LABELGATE_SYNC_REMOVE_DELAY=2h
LABELGATE_SYNC_AGENT_GRACE=72h

On this page

First stepsStartup and configurationlabelgate: config: ...config: cannot open the config fileopen store "/app/config/labelgate.db"api: cannot listen on :28111DockerCannot connect to the Docker daemonpermission denied on the Docker socketRemote Docker over tcp://Cloudflarecloudflare credential validation failedwas refused: give it the ... permissionno matching zoneunknown tunnel or no default tunnel configuredcannot reach the Cloudflare APICloudflare is rate-limiting this API tokenis invalid and Cloudflare temporarily blocks ittarget auto: cannot detect this host's public IPv4 addressHostname gives 502 or error 1033Conflictsconflict: existing record not owned by labelgateconflict: the A record ... is already managed byconflict: hostname ... is already managed by agentconflict: hostname ... already hasconflict: an older labelgate ... record ... still uses this hostnameLabelscontainer ...: label ...access policy "..." is not definedA container is ignored, with no errorAgentscannot connect to the main instance; retryingmain rejected this agentmust be at least 32 characters (agent token)another agent with ID "..." is already connectedAgent gets a new ID after the container is recreatedunsupported_versiondoes not match the agent's hostnames allow-listservice host "..." is a host name, which agents may only use if allow-listedAdded to agent.accept_services, still rejectedtoo many containersDashboard and APIAPI and dashboard disabled: api.token is emptyDashboard does not openThat token was rejected / 401 unauthorizedhealthcheck failedResources not removed, or removed unexpectedlyResources stay after the container is goneResources were deleted unexpectedly