Grafana Data Source Test Failed: 502 Bad Gateway
Grafana container pointed at `localhost:9090` instead of Docker service name or host IP.
Runs locally in browser
Free · No login
Independently Verified 2026-11-25
v4.1.0
Identifier: Grafana Data Source Test Failed
Platform: Observability
Common Root Causes:
- Grafana container pointed at `localhost:9090` instead of Docker service name or host IP.
Interactive Diagnostic Checklist
Verified Solutions:
- Use the Docker Compose service DNS name (`http://prometheus:9090`) on a shared network.
Safe Diagnostic Command:
docker exec grafana curl -v http://prometheus:9090/-/ready
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.
Technical Explanation
Grafana container pointed at `localhost:9090` instead of Docker service name or host IP. Recommended diagnostic: `docker exec grafana curl -v http://prometheus:9090/-/ready`. Remediation: Use the Docker Compose service DNS name (`http://prometheus:9090`) on a shared network.
Worked Examples
- Run `docker exec grafana curl -v http://prometheus:9090/-/ready` to verify root cause before applying the remediation.
Limitations & Assumptions
- Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.
Source References & Verification
Resource ID: err-grafana-datasource-bad-gateway-502 · Independently verified: 2026-11-25