Skip to main content

Troubleshooting

Common issues when running the Tunnel Agent and how to resolve them.

Error reference

HTTPResponse body / symptomCauseWhat to do
404{"error":"No tunnel found for tenant"}Agent not connectedCheck the agent is running, ZIHIN_TOKEN is correct, and outbound 443 to tunnel.zihin.ai is allowed
404{"error":"Service not found on tunnel: ..."}Agent connected, but no service with that nameThe services[].name in zihin-agent.yml must match the {service} segment of the endpoint configured in Zihin Cloud
401{"error":"Unauthorized"} (no agent log)Zihin side: invalid Bearer to the tunnel serverContact the Zihin team
401Body from your service; agent logs status: 401Credential in inject_headers rejected by the internal serviceFix the token/API key in inject_headers and restart
406Not Acceptable (MCP services)An Accept header in inject_headers overrides the one the MCP client sendsRemove Accept from inject_headers and restart
502Bad gatewayAgent connected, but the local request to the internal service failed (URL, port, TLS, network)Set log_level: debug; the line Fetch failed { code, error } shows the cause. See diagnostics below
503Too many concurrent streamsToo many simultaneous streaming (SSE) connectionsClose unused streams or contact the Zihin team
504Gateway timeoutThe internal service took longer than 120s to respondCheck the health of the internal service; avoid unfiltered queries

Connection codes (agent logs)

CodeMeaningWhat to do
4001Invalid or expired tokenCheck ZIHIN_TOKEN; rotate the token in the Console if needed
4002Connection limit for your tunnel reachedHarmless — the extra connection waits and retries. To use more, lower pool_size or ask the Zihin team to raise the limit
4003Tunnel not foundContact the Zihin team to verify provisioning

Other messages

MessageCauseWhat to do
Reconnect loopOutbound 443 blockedAllow outbound HTTPS/WSS to tunnel.zihin.ai
Agent token is requiredZIHIN_TOKEN not setSet the variable before starting
No services definedYAML missing servicesAdd at least one service
HOST_NOT_ALLOWEDHost policy restricts accessContact the Zihin team
RATE_LIMITEDToo many requests per minuteReduce frequency or request a limit increase

Diagnostics

Test from inside the container (for 502):

docker exec zihin-tunnel wget -qO- --no-check-certificate https://INTERNAL_HOST:PORT/
# If this fails, the container can't reach the service — try network_mode: host in docker-compose.yml

Test the internal service directly (from the host):

curl -sk -H "Authorization: Bearer YOUR_TOKEN" https://INTERNAL_HOST:PORT/api/endpoint

Enable debug logs — set log_level: debug in zihin-agent.yml (or ZIHIN_LOG_LEVEL=debug) and restart. Set it back to info afterwards.

Agent version:

docker exec zihin-tunnel node dist/index.js --version

Support

When contacting the Zihin team, include:

  • Agent logs at debug level
  • The X-Tunnel-Request-Id response header of a failing request (every tunnel response carries one)
  • The agent version and a short description of your setup (services, network, corporate proxy)