Skip to main content

AI Gateway Troubleshooting

Each section starts from what you see, names the possible causes in the order to check them, and gives the command or UI place that tells them apart. The meaning of every error code is in Error Codes.

Where to look​

PlaceWhat it tells you
Clients → client → AI Gateway (UI, Owner/Admin)The edge's gateway service state, the configuration version it applied, a behind: version chip when it missed a deploy, the extproc version, recent logs, and the conf.d files on its disk
Administration → JobsEach AI gateway deploy job (AI_GATEWAY_DEPLOY): which edges applied which version, and the edge's own refusal message
AI Gateway → MCP serversA warning naming the edges that hold MCP back
AI Gateway → ProvidersEach provider's status from its answers in the last 15 minutes
curl -s 127.0.0.1:9002/configz (on the edge)state, config_version, restored_last_good, extproc.{binary_version, version_string, ready, restarts}, render.last_error, reload.{failures, last_error}, the gateways, the providers (credentials redacted)
curl -s -o /dev/null -w '%{http_code}' 127.0.0.1:9002/readyz200 once the extproc runs a configuration
journalctl -u elchi-ai-gatewayThe supervisor's log, including the extproc's lines (prefixed extproc:)
Elchi OS consoleshow ai-gateway (state, configuration, gateways, providers, sinks, recent configuration events), show health (one AI gateway line), logs ai-gateway [n] [follow] [grep <pattern>], restart ai-gateway, system component status

state in /configz is one of init, ensuring-binary, rendering, starting, ready, degraded (no valid configuration to run; extproc not running), crash-loop (the extproc keeps exiting), stopping.

A change never reaches an edge​

Check: the deploy job under Administration → Jobs, then the client's AI Gateway tab. Compare its applied version with the behind chip, or with desired_version from GET /api/v3/ai-gateway/status?project=&client_id=.

SymptomCauseFix
The job's note says no connected client of the project runs the AI gateway (or the client does not run the AI gateway)The control plane pushes only to clients whose registration reports ai_gateway_version. The client registered before the gateway was installed, or the gateway is not installed.Install the gateway on the edge (Installation), then make the agent register again (systemctl restart elchi-client). The reconnect queues a deploy for that client. On Elchi OS, a changed gateway binary makes the agent register again on its own.
The client's tab says client not found in this project (or not connected)The client belongs to another project (its registration token is <uuid>--<project>), or it is not connectedOpen the AI Gateway page of the client's own project. Reconnect the client.
The edge shows behind: versionIt missed a deploy (it was offline, or the push failed)AI Gateway → Sync (or POST /api/v3/ai-gateway/sync). A client that connects again also gets a deploy of its own.
The tab says The client returned no AI gateway status (is elchi-ai-gateway installed on this edge?)The agent found no gateway on the edgeInstall it.
A save answered "deploy": {"enqueued": false, "error": …}The change is saved, but no job was queuedRun Sync.
MCP works on some projects but this edge got a set without MCPThe edge's gateway is older than v0.4.0: it gets the configuration without MCPUpgrade the gateway on that edge.

The edge refuses a push​

The agent stages the files and runs elchi-ai-gateway validate on them before it replaces anything. A refused push leaves conf.d and the running configuration unchanged. The job shows the edge's message, ai gateway rejected the config: …, with the validator's reason.

SymptomCauseFix
Job failed with ai gateway rejected the config: …The edge's gateway validates differently from the control plane. Usually the edge's gateway is older than the configuration's schema.Upgrade the gateway on the edge. Read the reason, then Sync.
/configz reload.failures grows and reload.last_error is set; config_version does not changeThe extproc refused the rendered configuration. The previous one keeps serving. A refused set is not retried until conf.d changes.Fix the reason in the UI and save. The journal line is config reload failed; last-good keeps serving with reason.
render.last_error is setThe configuration could not be rendered (config render failed; keeping last-good)The reason names the field. Fix it in the UI.
restored_last_good: trueconf.d was unusable at start, or the extproc refused it at start. The gateway runs the last accepted configuration from /var/lib/elchi/ai-gateway/last-good.json. The journal says serving the persisted last-good config.Fix the configuration, or Sync. On Elchi OS, show health warns serving the last accepted configuration: the pushed one was refused (…).
state: degraded and no last-goodNothing valid to run: the extproc is not running, and AI listeners answer nothingPush a valid configuration (Sync). show health says serving NO configuration: ….
config_version is empty and render.last_error says empty config directoryNo configuration was pushed yet: the edge is not registered, or its project has no AI gatewayExpected. On Elchi OS show health reports this as information, not a fault.

Run the same check by hand on the edge:

sudo -u elchi /etc/elchi/bin/elchi-ai-gateway validate /etc/elchi/elchi-ai-gateway/conf.d
# ok: config valid → exit 0
# <reason> → exit 1

The extproc does not start​

SymptomCauseFix
state: ensuring-binary; journal could not ensure extproc binary; retrying (every 10 s)The engine binary is missing and cannot be downloaded: no egress, a wrong index_url, or the archive has no build of the pinned versionOnline: check curl -sI https://archive.elchi.io/index.json from the edge (or your mirror). Offline: place the binary with --extproc-binary / extproc.binary in config.yaml (plus sha256). On Elchi OS: import extproc <path> <version> [sha256], or system component status.
The journal shows adopting extproc's version string from mismatch reportThe rendered version did not match the binary's own version string (the version gate). The gateway adopts the string the extproc names, renders again and restarts. This happens once per binary and string.Nothing. It heals itself. To avoid it, set extproc.version_string (or --extproc-version-string).
extproc still reports version mismatch after adopting its version string; giving up on self-healThe adopted string was refused tooSet --extproc-version-string / extproc.version_string to the binary's version string. Check that the binary is the pinned release. A development build reports dev.
state: crash-loop; journal extproc exited; will restart with consecutive_short_exits ≥ 5The extproc keeps exiting. Each short exit backs off 1 s, 2 s … up to 30 s.Read the extproc's own lines just before the exit (journalctl -u elchi-ai-gateway | grep extproc:): they name the reason.
extproc unresponsive; restartingThe extproc's admin /health stopped answeringThe gateway restarts it. If it repeats, read the extproc's lines before the restart.
The unit does not start on Elchi OSIts firewall guard failed to load: the gateway does not start with port 9064 openlogs ai-gateway; sudo nft list table inet elchi_ai_gateway.

404: model or host not found​

AnswerCauseFix
404 gateway_not_found: no AI gateway serves this host on listener <l>The request's Host is not one of the hosts of a gateway bound to this listener, and the listener has no default gatewayAdd the host to the gateway, bind the gateway to the listener, or set a default gateway on the listener (Listeners). Gateways bound to another listener are not reachable through this one.
404 model_not_found: the model is not served by gateway <gw>; …The model in the body is not in the gateway's model listGET /v1/models on the same host lists what the gateway serves. Add the model to the gateway.
404 with an empty bodyThe request reached the router without the extproc naming its model (the gateway's unrouted route)Check the path and body against the endpoints in Calling the Gateway.
404 not_found: this route is not served by an AI gatewayYour own route on an HCM with the AI gateway toggle onDedicate listeners to the AI gateway. Other routes on an AI HCM are not served.
503 gateway_not_ready … does not serve model … yetEnvoy already routes the model, but this edge's configuration does not have it yetWait for the deploy, or check that the edge did not refuse it (above). The answer carries retry-after: 5.

401 and 403 on keyed gateways​

AnswerCauseFix
401 invalid_api_keyNo key, a wrong key, a revoked or deleted key, or a disabled consumer. Also any request (including /v1/models) to a keyed gateway without a key.Send the key as Authorization: Bearer sk-elchi-…, x-api-key or api-key. A key is shown only once: if it is lost, create a new one on the consumer. A new key works on an edge once the deploy has applied there.
403 gateway_not_allowedThe consumer's gateway allowlist does not include this gatewayAdd the gateway to the consumer, or clear its gateway list.
403 model_not_allowedThe consumer's model or provider allowlist excludes the model. For a pooled model, every provider of it must be allowed.Edit the consumer's allowlists.
403 model_not_pricedThe consumer has a cost quota and the model has no price at the provider that serves itAdd the price in the price table (Quotas, Limits and Costs), or remove the cost quota.
403 files_not_allowed/v1/files on a keyed gatewayNot supported by design: files belong to the provider's account and would be shared by every consumer.
503 gateway_not_ready … as one that requires a key yetA new keyed gateway is in Envoy but not yet on this edge, or the edge refused the pushWait for the deploy, or check the job.
401 or 403 with no elchi codeThe provider refused the provider credentialAI Gateway → Providers: the provider status shows auth_error. Use Check on the provider, and enter its key again.

The edge's journal has one request denied line per consumer and code per minute, naming the consumer, gateway, phase and message:

journalctl -u elchi-ai-gateway --since -10min | grep '"request denied"'

422 unsupported API schema​

The extproc cannot translate this endpoint to the provider type that serves the model. The common case is /v1/chat/completions with a native anthropic provider: OpenAI-format clients reach Claude through aws-anthropic or gcp-anthropic, while a native anthropic provider serves /anthropic/v1/messages. The table is in Calling the Gateway. The configuration's notes at the top of the AI Gateway page (and the warnings of every save) name each native anthropic provider for this reason.

429: quotas​

AnswerCauseFix
429 quota_exceeded: consumer <c> used its quota of <limit>; it resets at <time>One of the consumer's quotas is used up. retry-after is the seconds until the reset. Days and months are UTC.Raise the quota on the consumer, or wait. AI Gateway → Consumers → consumer shows its quota use.
A consumer gets N times its quota across N edgesThe edges have no ClickHouse. Without it each edge counts only what it saw since it started, and a restart resets the count. The journal warns consumer quotas are edge-local: … at start.Configure usage.clickhouse_dsn on every edge. The counters re-read the other edges' usage every minute.
429 with no elchi codeThe provider's own rate limitThe provider status shows rate_limited. Add a second provider for the model (Gateways and Models).

503 and 413​

AnswerCauseFix
503 sensitive_scan_busy / sensitive_scan_incomplete (retry-after: 1)The sensitive-data scan had no free slot, or did not finish, within Envoy's 2 s checkRetry. If it persists, the edge is out of CPU for the scan, or the bodies are very large. Lower the policy's maxScanBytes, or add CPU.
413 sensitive_scan_too_largeThe body is larger than the policy scans, and the policy blocks a typeSend less, or raise maxScanBytes (Sensitive Data).
403 sensitive_dataThe body carries a type the policy blocks. The message names the types.Remove the value, or change the policy's action for that type. AI Gateway → Sensitive data lists the decisions. Try a sample with the policy test.
413 from EnvoyThe body is over 50 MiB, the most a gateway buffersSend a smaller request.
503 service_unavailable: the AI gateway has no configuration yetThis edge's gateway has applied nothingSee The edge refuses a push.
500 for every requestThe gateway or the extproc is down or restarting. The AI filters are fail-closed./configz state, journalctl -u elchi-ai-gateway.

Upstream errors and failover​

SymptomCauseFix
Provider status unreachableNo connection: DNS, refused, or TLSFrom the edge: curl -v https://<provider-host>/. Check the provider's upstream host and port. Behind a proxy on Elchi OS: set proxy.
Provider status timeoutNo answer in time. A model route waits 900 s of silence before Envoy cuts it.Use streaming for long answers. Check the provider.
Status server_error or resetThe provider answered 5xx, or broke the connection mid-answerFor a model several providers serve, set the gateway's failover so Envoy retries the next provider. Retries go to the level's other providers first; a fallback level serves only when the level above has no healthy provider.
Failover does not happenThe model has one provider, or the gateway's failover does not cover the failureSee Gateways and Models. A failed attempt behind a successful retry is not in the access log. Pool members show their outlier ejection in Envoy's /clusters.
Provider status idleNo answers in the last 15 minutesSend a request. Check on the provider asks its model list without spending tokens.

Usage or the request log is empty​

SymptomCauseFix
Usage, request log, provider status and decisions are all emptyThe edge has no ClickHouse DSN (empty disables every table), or an invalid one (journal: ClickHouse export disabled: invalid DSN)Plain Linux: set usage.clickhouse_dsn in /etc/elchi/elchi-ai-gateway/config.yaml (a re-run of the installer keeps the existing file), then systemctl restart elchi-ai-gateway. Elchi OS: set ai-gateway usage clickhouse <host:port> <db> <user> [tls], then apply.
The edge writes, but the UI shows nothingThe edge writes to a different ClickHouse than the controller reads, or under another project id (project in config.yaml)Point the edge at the controller's ClickHouse database. Check project.
The usage page answers clickhouse not configured; …The controller has no ClickHouseConfigure it on the controller.
The request log is empty but usage is notrequests.enabled: false, or the gateway's capture level is offSet the level to metadata or full on the gateway (Request Log).
Content is missing on a full rowContent is kept for the gateway's sampleRate share only. Content of a shredded key is unreadable (content_error).Raise sampleRate. Shredded content cannot be recovered.
Usage appears lateUsage is scraped every 30 s. While ClickHouse is unreachable, batches wait and are written when it comes back.Wait. The request log drops what its 4096-row queue cannot hold during a long outage.
Older days show no hourly rollup speedRollups are never backfilled. The controller reads the raw table for hours before a rollup existed.Nothing to fix. The numbers are the same.

MCP​

SymptomCauseFix
/mcp is not served on any listener of the projectMCP is held back: an edge of the project runs a gateway older than v0.4.0AI Gateway → MCP servers names the edges (GET /api/v3/ai-gateway/mcp-readiness). Upgrade them. A disconnected client with an old version holds MCP back too. Delete it if it is gone.
A tool is missing from tools/listThe consumer was not granted the tool or the server, the server's tool selector excludes it, or the gateway does not serve the serverEdit the consumer's MCP grants and the gateway's MCP servers (Grants and Quotas). The list is per consumer.
tool_not_allowedThe tool was called by its full name, <server>__<tool>, but it is not grantedGrant it.
The server answers 401/403 to a userA server with personal tokens: the user's token was not sent, or not from the startSend x-elchi-mcp-token: <token> (or x-elchi-mcp-token-<server> per server) on every request, from initialize on (Personal Tokens).
Calls fail with 500 call to <server> failed …The server is unreachable or answered an error, or the edge's MCP egress is closedDiscover the server's tools from the control plane (Discover) to tell the server from the edge. On the edge, check the egress next.
Elchi OS: every MCP call failsThe egress guard rule for the gateway's cgroup is missingsudo nft list table inet elchi_ai_gateway must show the socket cgroupv2 … "system.slice/elchi-ai-gateway.service" accept rule. The guard logs the MCP egress stays closed (no rule for …). restart ai-gateway adds it again.
Plain Linux: every MCP call failsEnvoy is not running as the user the firewall allows to answer, or Envoy's user did not exist at install (the installer warned)Re-run the installer with --envoy-user=<user>. Check with sudo nft list table inet elchi_ai_gateway.
A long tool call or SSE stream ends with 503The answer took longer than the MCP write timeout (15 minutes by default)Raise --mcp-write-timeout / ELCHI_AI_GATEWAY_MCP_WRITE_TIMEOUT on the edge.
413 mcp_request_too_largeThe request is over 4 MiBSend less per call.

AI Gateway → MCP calls lists every call with its status and class, newest first.

Getting the facts in one go​

On a plain Linux edge:

systemctl status elchi-ai-gateway --no-pager
curl -s 127.0.0.1:9002/configz | jq '{state, config_version, restored_last_good, extproc, render, reload}'
ls -l /etc/elchi/elchi-ai-gateway/conf.d /run/elchi-ai-gateway
sudo nft list table inet elchi_ai_gateway
journalctl -u elchi-ai-gateway --since -30min --no-pager | tail -100

On Elchi OS: show ai-gateway, show health, logs ai-gateway 200.