title: Prometheus - connect: no route to host. Even though the service is up
body: <p>When I access Prometheus targets, one of these targets is getting &quot;state down&quot;, even thoug I can access it on my browser (<a href="https://i.stack.imgur.com/vhz2N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vhz2N.png" alt="enter image description here" /></a>). I am problably missing something. I´d like to know what it is, because I have searched for it for some hours and I can´t find the reason. I even disabled the Windows firewall for a while, but it doesn´t work.</p>
  <p>I am using docker and Spring. The Rest services I created are working fine. (myIP is the localhost in the code and in the image).</p>
  <p>My docker is configurated as shown bellow.</p>
  <p>docker-compose.yml</p>
  <h1>Use root/example as user/password credentials</h1>
  <p>version: '3.8'</p>
  <p>services:</p>
  <pre><code>  mysql:
      image: mysql:8.0.22
      container_name: mysql
      ports:
        - 3306:3306
      environment:
        MYSQL_USER: atendente
        MYSQL_PASSWORD: atendente
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: plano_saude_db
    jaeger:
      image: jaegertracing/all-in-one:1.21
      container_name: jaeger
      ports:
        - 5775:5775/udp
        - 6831:6831/udp
        - 5778:5778
        - 16686:16686
        - 14268:14268
        - 14250:14250
        - 9411:9411
    prometheus:
      image: prom/prometheus:v2.24.1
      container_name: prometheus
      ports:
        - 9090:9090
      volumes:
        - ./prometheus.yml:/etc/prometheus/prometheus.yml
      command:
        '--config.file=/etc/prometheus/prometheus.yml'
  </code></pre>
  <p>prometheus.yml:</p>
  <p>global:
  scrape_interval:     15s # By default, scrape targets every 15 seconds.</p>
  <pre><code># A scrape configuration containing exactly one endpoint to scrape:
  # Here it's Prometheus itself.
  scrape_configs:
    - job_name: 'prometheus'
      scrape_interval: 5s
      static_configs:
        - targets: ['localhost:9090']
    - job_name: 'planosaude-sys'
      scrape_interval: 5s
      metrics_path: '/actuator/prometheus'
      static_configs:
        - targets: ['&lt;myIp&gt;:8080']
  </code></pre>
  <p>Accessing http://myIp:8080/actuator/prometheus I get the following:</p>
  <pre><code># HELP jdbc_connections_idle Number of established but idle connections.
  # TYPE jdbc_connections_idle gauge jdbc_connections_idle{name=&quot;dataSource&quot;,} 10.0
  # HELP tomcat_sessions_active_max_sessions  
  # TYPE tomcat_sessions_active_max_sessions gauge tomcat_sessions_active_max_sessions 0.0
  # HELP jvm_memory_max_bytes The maximum amount of memory in bytes that can be used for memory management
  # TYPE jvm_memory_max_bytes gauge jvm_memory_max_bytes{area=&quot;nonheap&quot;,id=&quot;CodeHeap 'profiled
  nmethods'&quot;,} 1.2288E8 jvm_memory_max_bytes{area=&quot;heap&quot;,id=&quot;G1 Survivor
  Space&quot;,} -1.0 jvm_memory_max_bytes{area=&quot;heap&quot;,id=&quot;G1 Old Gen&quot;,}
  1.579155456E9 jvm_memory_max_bytes{area=&quot;nonheap&quot;,id=&quot;Metaspace&quot;,} -1.0 jvm_memory_max_bytes{area=&quot;nonheap&quot;,id=&quot;CodeHeap 'non-nmethods'&quot;,} 5898240.0 jvm_memory_max_bytes{area=&quot;heap&quot;,id=&quot;G1
  Eden Space&quot;,} -1.0 jvm_memory_max_bytes{area=&quot;nonheap&quot;,id=&quot;Compressed
  Class Space&quot;,} 1.073741824E9
  jvm_memory_max_bytes{area=&quot;nonheap&quot;,id=&quot;CodeHeap 'non-profiled
  nmethods'&quot;,} 1.2288E8
  # HELP jvm_threads_peak_threads The peak live thread count since the Java virtual machine started or peak was reset
  # TYPE jvm_threads_peak_threads gauge jvm_threads_peak_threads 21.0
  # HELP jvm_threads_states_threads The current number of threads having NEW state
  # TYPE jvm_threads_states_threads gauge jvm_threads_states_threads{state=&quot;runnable&quot;,} 9.0
  jvm_threads_states_threads{state=&quot;blocked&quot;,} 0.0
  jvm_threads_states_threads{state=&quot;waiting&quot;,} 5.0
  jvm_threads_states_threads{state=&quot;timed-waiting&quot;,} 6.0
  jvm_threads_states_threads{state=&quot;new&quot;,} 0.0
  jvm_threads_states_threads{state=&quot;terminated&quot;,} 0.0
  # HELP jdbc_connections_max Maximum number of active connections that can be allocated at the same time.
  # TYPE jdbc_connections_max gauge jdbc_connections_max{name=&quot;dataSource&quot;,} 10.0
  # HELP process_uptime_seconds The uptime of the Java virtual machine
  # TYPE process_uptime_seconds gauge process_uptime_seconds 2484.248
  # HELP logback_events_total Number of error level events that made it to the logs
  # TYPE logback_events_total counter logback_events_total{level=&quot;warn&quot;,} 1.0
  logback_events_total{level=&quot;debug&quot;,} 0.0
  logback_events_total{level=&quot;error&quot;,} 0.0
  logback_events_total{level=&quot;trace&quot;,} 0.0
  logback_events_total{level=&quot;info&quot;,} 15.0
  # HELP jvm_classes_loaded_classes The number of classes that are currently loaded in the Java virtual machine
  # TYPE jvm_classes_loaded_classes gauge jvm_classes_loaded_classes 12647.0
  # HELP jvm_threads_live_threads The current number of live threads including both daemon and non-daemon threads
  # TYPE jvm_threads_live_threads gauge jvm_threads_live_threads 20.0
  # HELP hikaricp_connections_usage_seconds Connection usage time
  # TYPE hikaricp_connections_usage_seconds summary hikaricp_connections_usage_seconds_count{pool=&quot;HikariPool-1&quot;,} 0.0
  hikaricp_connections_usage_seconds_sum{pool=&quot;HikariPool-1&quot;,} 0.0
  # HELP hikaricp_connections_usage_seconds_max Connection usage time
  # TYPE hikaricp_connections_usage_seconds_max gauge hikaricp_connections_usage_seconds_max{pool=&quot;HikariPool-1&quot;,} 0.0
  # HELP jvm_gc_max_data_size_bytes Max size of long-lived heap memory pool
  # TYPE jvm_gc_max_data_size_bytes gauge jvm_gc_max_data_size_bytes 1.579155456E9
  # HELP jvm_buffer_total_capacity_bytes An estimate of the total capacity of the buffers in this pool
  # TYPE jvm_buffer_total_capacity_bytes gauge jvm_buffer_total_capacity_bytes{id=&quot;mapped - 'non-volatile memory'&quot;,}
  0.0 jvm_buffer_total_capacity_bytes{id=&quot;mapped&quot;,} 0.0 jvm_buffer_total_capacity_bytes{id=&quot;direct&quot;,} 32768.0
  # HELP jvm_memory_committed_bytes The amount of memory in bytes that is committed for the Java virtual machine to use
  # TYPE jvm_memory_committed_bytes gauge jvm_memory_committed_bytes{area=&quot;nonheap&quot;,id=&quot;CodeHeap 'profiled
  nmethods'&quot;,} 1.1337728E7 jvm_memory_committed_bytes{area=&quot;heap&quot;,id=&quot;G1
  Survivor Space&quot;,} 2097152.0
  jvm_memory_committed_bytes{area=&quot;heap&quot;,id=&quot;G1 Old Gen&quot;,} 3.7748736E7
  jvm_memory_committed_bytes{area=&quot;nonheap&quot;,id=&quot;Metaspace&quot;,} 7.0582272E7
  jvm_memory_committed_bytes{area=&quot;nonheap&quot;,id=&quot;CodeHeap
  'non-nmethods'&quot;,} 2555904.0
  jvm_memory_committed_bytes{area=&quot;heap&quot;,id=&quot;G1 Eden Space&quot;,} 2.62144E7
  jvm_memory_committed_bytes{area=&quot;nonheap&quot;,id=&quot;Compressed Class
  Space&quot;,} 9109504.0
  jvm_memory_committed_bytes{area=&quot;nonheap&quot;,id=&quot;CodeHeap 'non-profiled
  nmethods'&quot;,} 4325376.0
  # HELP hikaricp_connections_pending Pending threads
  # TYPE hikaricp_connections_pending gauge hikaricp_connections_pending{pool=&quot;HikariPool-1&quot;,} 0.0
  # HELP tomcat_sessions_alive_max_seconds  
  # TYPE tomcat_sessions_alive_max_seconds gauge tomcat_sessions_alive_max_seconds 0.0
  # HELP tomcat_sessions_active_current_sessions  
  # TYPE tomcat_sessions_active_current_sessions gauge tomcat_sessions_active_current_sessions 0.0
  # HELP jdbc_connections_min Minimum number of idle connections in the pool.
  # TYPE jdbc_connections_min gauge jdbc_connections_min{name=&quot;dataSource&quot;,} 10.0
  # HELP jdbc_connections_active Current number of active connections that have been allocated from the data source.
  # TYPE jdbc_connections_active gauge jdbc_connections_active{name=&quot;dataSource&quot;,} 0.0
  # HELP jvm_threads_daemon_threads The current number of live daemon threads
  # TYPE jvm_threads_daemon_threads gauge jvm_threads_daemon_threads 16.0
  # HELP jvm_memory_used_bytes The amount of used memory
  # TYPE jvm_memory_used_bytes gauge jvm_memory_used_bytes{area=&quot;nonheap&quot;,id=&quot;CodeHeap 'profiled
  nmethods'&quot;,} 1.1297792E7 jvm_memory_used_bytes{area=&quot;heap&quot;,id=&quot;G1
  Survivor Space&quot;,} 1651760.0 jvm_memory_used_bytes{area=&quot;heap&quot;,id=&quot;G1
  Old Gen&quot;,} 2.7873792E7
  jvm_memory_used_bytes{area=&quot;nonheap&quot;,id=&quot;Metaspace&quot;,} 7.0095672E7
  jvm_memory_used_bytes{area=&quot;nonheap&quot;,id=&quot;CodeHeap 'non-nmethods'&quot;,}
  1357312.0 jvm_memory_used_bytes{area=&quot;heap&quot;,id=&quot;G1 Eden Space&quot;,} 1.2582912E7 jvm_memory_used_bytes{area=&quot;nonheap&quot;,id=&quot;Compressed Class Space&quot;,} 8883800.0 jvm_memory_used_bytes{area=&quot;nonheap&quot;,id=&quot;CodeHeap
  'non-profiled nmethods'&quot;,} 4293632.0
  # HELP tomcat_sessions_rejected_sessions_total  
  # TYPE tomcat_sessions_rejected_sessions_total counter tomcat_sessions_rejected_sessions_total 0.0
  # HELP process_cpu_usage The &quot;recent cpu usage&quot; for the Java Virtual Machine process
  # TYPE process_cpu_usage gauge process_cpu_usage 0.0013668563296602018
  # HELP hikaricp_connections_active Active connections
  # TYPE hikaricp_connections_active gauge hikaricp_connections_active{pool=&quot;HikariPool-1&quot;,} 0.0
  # HELP tomcat_sessions_expired_sessions_total  
  # TYPE tomcat_sessions_expired_sessions_total counter tomcat_sessions_expired_sessions_total 0.0
  # HELP jvm_buffer_count_buffers An estimate of the number of buffers in the pool
  # TYPE jvm_buffer_count_buffers gauge jvm_buffer_count_buffers{id=&quot;mapped - 'non-volatile memory'&quot;,} 0.0
  jvm_buffer_count_buffers{id=&quot;mapped&quot;,} 0.0
  jvm_buffer_count_buffers{id=&quot;direct&quot;,} 4.0
  # HELP hikaricp_connections_creation_seconds_max Connection creation time
  # TYPE hikaricp_connections_creation_seconds_max gauge hikaricp_connections_creation_seconds_max{pool=&quot;HikariPool-1&quot;,} 0.0
  # HELP hikaricp_connections_creation_seconds Connection creation time
  # TYPE hikaricp_connections_creation_seconds summary hikaricp_connections_creation_seconds_count{pool=&quot;HikariPool-1&quot;,} 10.0
  hikaricp_connections_creation_seconds_sum{pool=&quot;HikariPool-1&quot;,} 0.943
  # HELP jvm_gc_memory_promoted_bytes_total Count of positive increases in the size of the old generation memory pool before GC to after GC
  # TYPE jvm_gc_memory_promoted_bytes_total counter jvm_gc_memory_promoted_bytes_total 1.356288E7
  # HELP system_cpu_usage The &quot;recent cpu usage&quot; for the whole system
  # TYPE system_cpu_usage gauge system_cpu_usage 0.07962681468188304
  # HELP http_server_requests_seconds  
  # TYPE http_server_requests_seconds summary http_server_requests_seconds_count{exception=&quot;None&quot;,method=&quot;GET&quot;,outcome=&quot;SUCCESS&quot;,status=&quot;200&quot;,uri=&quot;/actuator/prometheus&quot;,}
  1.0 http_server_requests_seconds_sum{exception=&quot;None&quot;,method=&quot;GET&quot;,outcome=&quot;SUCCESS&quot;,status=&quot;200&quot;,uri=&quot;/actuator/prometheus&quot;,}
  2.7254424
  # HELP http_server_requests_seconds_max  
  # TYPE http_server_requests_seconds_max gauge http_server_requests_seconds_max{exception=&quot;None&quot;,method=&quot;GET&quot;,outcome=&quot;SUCCESS&quot;,status=&quot;200&quot;,uri=&quot;/actuator/prometheus&quot;,}
  0.0
  # HELP hikaricp_connections_timeout_total Connection timeout total count
  # TYPE hikaricp_connections_timeout_total counter hikaricp_connections_timeout_total{pool=&quot;HikariPool-1&quot;,} 0.0
  # HELP hikaricp_connections_max Max connections
  # TYPE hikaricp_connections_max gauge hikaricp_connections_max{pool=&quot;HikariPool-1&quot;,} 10.0
  # HELP jvm_gc_live_data_size_bytes Size of long-lived heap memory pool after reclamation
  # TYPE jvm_gc_live_data_size_bytes gauge jvm_gc_live_data_size_bytes 0.0
  # HELP jvm_classes_unloaded_classes_total The total number of classes unloaded since the Java virtual machine has started execution
  # TYPE jvm_classes_unloaded_classes_total counter jvm_classes_unloaded_classes_total 0.0
  # HELP hikaricp_connections_idle Idle connections
  # TYPE hikaricp_connections_idle gauge hikaricp_connections_idle{pool=&quot;HikariPool-1&quot;,} 10.0
  # HELP hikaricp_connections Total connections
  # TYPE hikaricp_connections gauge hikaricp_connections{pool=&quot;HikariPool-1&quot;,} 10.0
  # HELP jvm_gc_pause_seconds Time spent in GC pause
  # TYPE jvm_gc_pause_seconds summary jvm_gc_pause_seconds_count{action=&quot;end of minor GC&quot;,cause=&quot;Metadata GC
  Threshold&quot;,} 1.0 jvm_gc_pause_seconds_sum{action=&quot;end of minor
  GC&quot;,cause=&quot;Metadata GC Threshold&quot;,} 0.004
  jvm_gc_pause_seconds_count{action=&quot;end of minor GC&quot;,cause=&quot;G1
  Evacuation Pause&quot;,} 9.0 jvm_gc_pause_seconds_sum{action=&quot;end of minor
  GC&quot;,cause=&quot;G1 Evacuation Pause&quot;,} 0.038
  # HELP jvm_gc_pause_seconds_max Time spent in GC pause
  # TYPE jvm_gc_pause_seconds_max gauge jvm_gc_pause_seconds_max{action=&quot;end of minor GC&quot;,cause=&quot;Metadata GC
  Threshold&quot;,} 0.0 jvm_gc_pause_seconds_max{action=&quot;end of minor
  GC&quot;,cause=&quot;G1 Evacuation Pause&quot;,} 0.0
  # HELP jvm_gc_memory_allocated_bytes_total Incremented for an increase in the size of the (young) heap memory pool after one GC to before the
  next
  # TYPE jvm_gc_memory_allocated_bytes_total counter jvm_gc_memory_allocated_bytes_total 2.42221056E8
  # HELP hikaricp_connections_acquire_seconds Connection acquire time
  # TYPE hikaricp_connections_acquire_seconds summary hikaricp_connections_acquire_seconds_count{pool=&quot;HikariPool-1&quot;,} 0.0
  hikaricp_connections_acquire_seconds_sum{pool=&quot;HikariPool-1&quot;,} 0.0
  # HELP hikaricp_connections_acquire_seconds_max Connection acquire time
  # TYPE hikaricp_connections_acquire_seconds_max gauge hikaricp_connections_acquire_seconds_max{pool=&quot;HikariPool-1&quot;,} 0.0
  # HELP process_start_time_seconds Start time of the process since unix epoch.
  # TYPE process_start_time_seconds gauge process_start_time_seconds 1.631847251003E9
  # HELP tomcat_sessions_created_sessions_total  
  # TYPE tomcat_sessions_created_sessions_total counter tomcat_sessions_created_sessions_total 0.0
  # HELP jvm_buffer_memory_used_bytes An estimate of the memory that the Java virtual machine is using for this buffer pool
  # TYPE jvm_buffer_memory_used_bytes gauge jvm_buffer_memory_used_bytes{id=&quot;mapped - 'non-volatile memory'&quot;,} 0.0
  jvm_buffer_memory_used_bytes{id=&quot;mapped&quot;,} 0.0
  jvm_buffer_memory_used_bytes{id=&quot;direct&quot;,} 32768.0
  # HELP system_cpu_count The number of processors available to the Java virtual machine
  # TYPE system_cpu_count gauge system_cpu_count 8.0
  # HELP hikaricp_connections_min Min connections
  # TYPE hikaricp_connections_min gauge hikaricp_connections_min{pool=&quot;HikariPool-1&quot;,} 10.0
  </code></pre>
  <p>Pom.xml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.5.4&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.planosaude&lt;/groupId&gt;
      &lt;artifactId&gt;planosaude-sys&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;planosaude-sys&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
      &lt;properties&gt;
          &lt;java.version&gt;11&lt;/java.version&gt;
      &lt;/properties&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.micrometer&lt;/groupId&gt;
              &lt;artifactId&gt;micrometer-registry-prometheus&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
                  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  <p>If I use docker.for.win.localhost, I get the error:</p>
  <blockquote>
  <p>'dial tcp: lookup docker.for.win.localhost on 127.0.0.11:53: no such
  host&quot;.</p>
  </blockquote>
  <p>I am trying to solve this new error now.</p>
  <p><strong>Solved</strong></p>
  <p>It works if I use <em>host.docker.internal</em> instead.</p>