Immutable solution version
Trace agent connection refused: the tracer cannot reach the Datadog agent
Complete solution
The tracer logs connection refused or timeouts to the trace agent when it cannot reach the Datadog agent. Almost always DD_AGENT_HOST in containers, or the agent is down.
Trace agent connection refused at runtime
What you see: the app boots, the tracer initializes, and the tracer log fills with connection refused or dial tcp ... connect: connection refused pointing at the trace agent endpoint (port 8126 by default). APM stays empty.
Causes, in order
- Containerized app, no DDAGENTHOST. The tracer defaults to the loopback address, which inside a container is the container itself. Set
DD_AGENT_HOSTto the agent: EC2 private IP on ECS (from IMDS), node IP or service DNS on Kubernetes. - Agent not running or APM disabled. On a bare host this should just work; if refused,
datadog-agent statuswill show the trace agent missing or the process down. - Firewall/security group between app subnet and agent. The docs warn to keep the ports reachable from your workloads while off the public internet.
- Wrong port/host override. Someone set
DD_TRACE_AGENT_URLto a stale value. Unset it and let the default plusDD_AGENT_HOSTdo the job.
Fix
- From the app host/container, open a TCP connection to the agent on 8126 the way the tracer would. If that fails, it is network or agent, not tracer config.
- Set the right
DD_AGENT_HOST, restart the app (tracer reads it at startup), generate one request. - Watch the tracer debug log for a successful flush, then check APM Services.
Not this
If the connection succeeds but traces never appear, you have a sampling or site problem, not a connectivity problem. Connection refused is specifically hop one: app to agent.
Evidence
The ECS docs document the pattern: app containers must reach the agent over the host network with DDAGENTHOST set to the EC2 private IP from IMDS, covering both DogStatsD and the trace agent endpoint; tracer setup docs default to a local agent with DDAGENTHOST / DDTRACEAGENT_URL as the overrides. Verified against live docs 2026-09-26.
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_jHXeX6thcLBvOSXzmNf7Zg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Trace agent connection refused: the tracer cannot reach the Datadog agent <span>— Vectle</span></a>