Connection refused

Check proxy reachability and network access.

Connection refused

Cause: the ArmorIQ Proxy is not reachable.

Test connectivity

The SDK ships httpx, so use that rather than adding requests as an extra dependency just for this check.

import httpx

from armoriq_sdk import ArmorIQClient

client = ArmorIQClient()          # reads ARMORIQ_API_KEY
proxy_url = client.proxy_endpoint  # whatever your config actually resolved to

try:
    response = httpx.get(f"{proxy_url}/health", timeout=5.0)
    if response.status_code == 200:
        print(f"Proxy reachable at {proxy_url}")
    else:
        print(f"Proxy returned {response.status_code}")
except httpx.ConnectError:
    print("Cannot connect to proxy - check URL and network")
except httpx.TimeoutException:
    print("Connection timed out - check firewall")

Reading client.proxy_endpoint rather than hardcoding a URL matters: the endpoint is resolved from ARMORIQ_ENV, then any PROXY_ENDPOINT override, then the environment default. Hardcoding a host is the most common reason this check passes while the SDK still fails, or vice versa.

Common causes

SymptomLikely cause
ConnectError on every callWrong endpoint for your environment, or egress blocked
Works locally, fails in CIRunner has no outbound access to *.armoriq.ai
Works for the proxy but get_intent_token failsIAP endpoint differs from the proxy; check both
401 rather than a connection errorReachable but the API key is rejected - not a connectivity problem

Check which endpoints the SDK resolved

from armoriq_sdk import ArmorIQClient

client = ArmorIQClient()
print("proxy:  ", client.proxy_endpoint)
print("backend:", client.backend_endpoint)
print("iap:    ", client.iap_endpoint)

Endpoint precedence, highest first:

  1. explicit constructor arguments (proxy_endpoint=, iap_endpoint=, backend_endpoint=)
  2. per-endpoint env vars: PROXY_ENDPOINT, IAP_ENDPOINT, BACKEND_ENDPOINT
  3. use_production=False, which forces localhost regardless of ARMORIQ_ENV
  4. ARMORIQ_ENV (production, staging, or local)
  5. the environment baked into the installed package

Verified per environment with an ak_live_ key:

ARMORIQ_ENVbackendproxy
productionhttps://api.armoriq.aihttps://proxy.armoriq.ai
staginghttps://staging-api.armoriq.aihttps://cloud-run-proxy.armoriq.io
localhttp://127.0.0.1:3000http://127.0.0.1:3001

The IAP is https://iap.armoriq.ai, https://iap-staging.armoriq.ai, and http://127.0.0.1:8080 respectively.

On local, connection refused usually just means the services are not running. Check ports 3000 (backend), 3001 (proxy) and 8080 (IAP).

ak_claw_ keys ignore ARMORIQ_ENV. An ArmorClaw key resolves to the ArmorClaw endpoint family (*.armorclaw.io) and switches on use_production alone, because ArmorClaw has no staging row. So ARMORIQ_ENV=local with an ak_claw_ key still points at the remote ArmorClaw hosts, which is a confusing way to see connection errors. Pass use_production=False instead.

On this page