Introduction
Prometheus cannot scrape metrics from configured targets. Targets show as down in the UI and metrics are not being collected.
Symptoms
Prometheus UI shows target down:
Status: Down
Error: Get "http://target:9090/metrics": dial tcp 10.0.0.1:9090: connection refused
Last Scrape: NeverPrometheus logs:
```bash $ journalctl -u prometheus -f
level=error ts=2024-01-01T00:00:00.000Z caller=scrape.go:123 component="scrape manager" msg="scrape failed" target=target:9090 err="connection refused" ```
Common Causes
- 1.Target not running - Application or exporter process stopped
- 2.Wrong endpoint - Incorrect URL or port configured
- 3.Network blocking - Firewall or network policy blocking access
- 4.DNS resolution - Target hostname not resolving
- 5.Authentication - Target requires auth but not configured
- 6.TLS issues - Certificate validation failing
- 7.Scrape timeout - Endpoint responding too slowly
Step-by-Step Fix
- 1.Check logs for specific error messages
- 2.Verify configuration settings
- 3.Test network connectivity
- 4.Review recent changes
- 5.Apply corrective action
- 6.Verify the fix
Step 1: Check Prometheus Target Status
```bash # Check Prometheus UI: # http://localhost:9090/targets
# API query: curl -s http://localhost:9090/api/v1/targets | jq
# List all targets: curl -s http://localhost:9090/api/v1/targets | jq '.data.activeTargets[] | {job: .labels.job, health: .health, lastError: .lastError}'
# Count healthy vs unhealthy: curl -s http://localhost:9090/api/v1/targets | jq '[.data.activeTargets[].health] | group_by(.) | map({health: .[0], count: length})' ```
Step 2: Check Prometheus Configuration
```bash # View Prometheus config: cat /etc/prometheus/prometheus.yml
# Validate config syntax: promtool check config /etc/prometheus/prometheus.yml
# Reload config: curl -X POST http://localhost:9090/-/reload systemctl reload prometheus ```
Step 3: Test Target Endpoint Accessibility
```bash # Test direct HTTP access: curl -v http://target:9090/metrics
# Test with timeout: curl -m 10 http://target:9090/metrics
# Check if port is listening on target: ssh target 'ss -tlnp | grep 9090'
# Test network connectivity: nc -zv target 9090
# Check DNS resolution: nslookup target dig target ```
Step 4: Check Target Application Status
```bash # On target host:
# Check if exporter running: systemctl status node_exporter
# Check process: ps aux | grep exporter
# Check port: ss -tlnp | grep 9090
# Test locally on target: curl http://localhost:9090/metrics
# Start exporter if not running: systemctl start node_exporter ```
Step 5: Check Firewall and Network
```bash # On Prometheus host - check outbound: iptables -L OUTPUT -n -v
# On target host - check inbound: iptables -L INPUT -n -v | grep 9090
# Allow Prometheus to scrape: iptables -I INPUT -s prometheus_ip -p tcp --dport 9090 -j ACCEPT
# Test connectivity after firewall change: nc -zv target 9090 ```
Step 6: Check TLS Configuration
```bash # For HTTPS endpoints:
# Check certificate: curl -v https://target:9090/metrics
# TLS error example: # SSL certificate problem: unable to get local issuer certificate
# Test TLS connection: openssl s_client -connect target:9090 -showcerts
# Check certificate expiration: openssl s_client -connect target:9090 2>/dev/null | openssl x509 -noout -dates ```
Step 7: Check Authentication Configuration
```bash # For targets requiring authentication:
# Basic auth config in prometheus.yml: scrape_configs: - job_name: myapp basic_auth_configs: username: admin password: secret
# Test auth manually: curl -u admin:secret http://target:9090/metrics
# Token auth: curl -H "Authorization: Bearer mytoken" http://target:9090/metrics ```
Step 8: Check Scrape Interval and Timeout
```bash # Check global scrape interval: curl -s http://localhost:9090/api/v1/status/config | jq '.data.global.scrape_interval'
# Check job-specific: cat /etc/prometheus/prometheus.yml | grep -A 5 scrape_interval
# Set scrape timeout: scrape_configs: - job_name: slow-target scrape_interval: 30s scrape_timeout: 10s ```
Step 9: Check Prometheus Logs
```bash # View Prometheus logs: journalctl -u prometheus -f
# Check for scrape errors: journalctl -u prometheus --since "1 hour ago" | grep -i "scrape"
# Look for connection errors: journalctl -u prometheus | grep -E "connection refused|timeout|unreachable"
# Enable debug logging: # In prometheus.yml: log.level: debug systemctl restart prometheus ```
Step 10: Verify and Monitor Scrape
```bash # Check target status: curl -s http://localhost:9090/api/v1/targets | jq '.data.activeTargets[] | select(.labels.job=="myapp") | .health'
# Query metrics from target: curl -s 'http://localhost:9090/api/v1/query?query=up{job="myapp"}' | jq '.data.result[].value[1]'
# Monitor targets in real-time: watch -n 5 'curl -s http://localhost:9090/api/v1/targets | jq ".data.activeTargets[].health"' ```
Prometheus Scrape Error Checklist
| Check | Command | Expected |
|---|---|---|
| Target health | /api/v1/targets | health: up |
| Endpoint access | curl /metrics | Metrics returned |
| Network | nc -zv | Port open |
| DNS resolution | nslookup | IP returned |
| Config syntax | promtool check | SUCCESS |
| Firewall | iptables -L | Port allowed |
Verification
```bash # 1. Check target status curl -s http://localhost:9090/api/v1/targets | jq '.data.activeTargets[] | .health' // "up"
# 2. Query metrics from target curl -s 'http://localhost:9090/api/v1/query?query=up{job="myapp"}' | jq '.data.result[].value[1]' // "1"
# 3. Test endpoint directly curl http://target:9090/metrics // Metrics returned
# 4. Check no errors in logs journalctl -u prometheus --since "5 min ago" | grep -i "scrape failed" // No output ```
Related Issues
- [Fix Prometheus Query Timeout](/articles/fix-prometheus-query-timeout)
- [Fix Grafana Dashboard Not Loading](/articles/fix-grafana-dashboard-not-loading)
Related Articles
- [WordPress troubleshooting: Fix IAM Timeout Error - Complete Trouble](fix-iam-timeout-error)
- [Technical troubleshooting: Fix Cloudwatch Alarm Not Triggering Issue in Monit](cloudwatch-alarm-not-triggering)
- [Fix Datadog Agent Not Sending Metrics Issue in Monitoring](datadog-agent-not-sending-metrics)
- [Fix Elasticsearch Cluster Red Yellow Status Issue in Monitoring](elasticsearch-cluster-red-yellow-status)
- [Fix Alertmanager Notification Failed](fix-alertmanager-notification-failed)
<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "TechArticle", "headline": "Fix Prometheus Scrape Error", "description": "Troubleshoot Prometheus scrape error. Check targets, endpoints, scrape intervals.", "url": "https://www.fixwikihub.com/fix-prometheus-scrape-error", "publisher": { "@type": "Organization", "name": "FixWikiHub", "url": "https://www.fixwikihub.com" }, "author": { "@type": "Person", "name": "FixWikiHub Editorial Team" }, "datePublished": "2026-04-11T07:31:27.090Z", "dateModified": "2026-04-11T07:31:27.090Z" } </script>