Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

564
Views
Cannot connect from asgi app (FastApi) to Datadog Agent running on Docker

I am trying to connect to datadog from my fastapi backend. I am currently trying to do this on localhost using a docker-compose file to let both my datadog-agent and my backend-container run in the same network. Here is a minimal example

dd-minimal
 - docker-compose.yml
 - backend-client
   - Dockerfile
   - app
     - main.py

docker-compose.yml


version: "3.7"

networks:
  my_network:

services:
  datadog:
    image: datadog/agent:latest
    environment:
     DD_API_KEY: <my-api-key>
     DD_APM_ENABLED: 'true'
    volumes:
     - /var/run/docker.sock:/var/run/docker.sock
     - /proc/:/host/proc/:ro
     - /sys/fs/cgroup:/host/sys/fs/cgroup:ro
    ports: 
      - "8126:8126/tcp"
    networks:
      - my_network
    
  backend-web-client:
    image: gql-backend-api
    build:
      dockerfile: Dockerfile
      context: ./backend-client
    environment:
      DD_TRACE_ANALYTICS_ENABLED: 'true'
      DD_AGENT_HOST: 172.21.0.2
    ports: 
      - "5555:8080"
    networks:
      - my_network
    depends_on: 
      - datadog

Dockerfile

FROM tiangolo/uvicorn-gunicorn-fastapi:python3.8-slim

COPY ./app /app
RUN pip install ddtrace==0.41.0

CMD exec ddtrace-run gunicorn --bind :8080 --workers 1 --threads 8 --timeout 0  main:api -k uvicorn.workers.UvicornWorker

main.py

import os

import uvicorn
from fastapi import FastAPI

api = FastAPI()

if __name__ == "__main__":
    uvicorn.run(api, host="127.0.0.1", port=int(os.environ.get("PORT", 8080)))

I run docker-compose up and then check the ip of my dd-container with

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dd-minimal_datadog_1

and update it in the compose file.

When I then again run docker-compose up, I get the following error

- DATADOG TRACER DIAGNOSTIC - Agent not reachable. Exception raised: [Errno 111] Connection refused.

Any help would be very appreciated

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You may need to set the environment variable DD_APM_NON_LOCAL_TRAFFIC=true in your datadog agent container.

Ref: https://docs.datadoghq.com/agent/docker/apm/?tab=linux#docker-apm-agent-environment-variables

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!