title: prometheus cannot scrape node-exporter on own host
body: <p>I have a host with the ip <code>10.0.0.6</code> on a private network that runs prometheus.</p>
  <p>This and several other hosts in the network run a node-exporter via docker-compose where <code>{{ private_ip }}</code> is automatically replaced by the actual private ip:</p>
  <pre><code>  node-exporter:
      image: prom/node-exporter:v1.3.1
      pid: host
      volumes:
        - '/:/host:ro,rslave'
      command:
        - '--path.rootfs=/host'
      expose:
        - 9100
      ports:
        - {{ private_ip }}:9100:9100
      restart: unless-stopped
  </code></pre>
  <p>This is my <code>prometheus.yml</code>:</p>
  <pre><code>global:
    scrape_interval:     5s
    evaluation_interval: 5s
  
  scrape_configs:
    - job_name: 'node-exporters'
      scheme: http
      basic_auth:
        username: {{ node_exporter_auth_user }}
        password: {{ node_exporter_auth_password }}
      hetzner_sd_configs:
        - role: &quot;hcloud&quot;
          bearer_token: &quot;{{ hcloud_prometheus_token }}&quot;
      relabel_configs:
        - source_labels: [__meta_hetzner_hcloud_label_node_exporter]
          action: keep
          regex: true
        - source_labels: [__meta_hetzner_hcloud_label_node_exporter, __meta_hetzner_hcloud_private_ipv4_mynet]
          action: replace
          regex: true;(.*)
          target_label: __address__
          replacement: '$1:9100'
        - action: labelmap
          regex: __meta_hetzner_hcloud_(.+)
        - action: labelmap
          regex: __meta_hetzner_server_(.+)
  </code></pre>
  <p>Prometheus is able to scrape all other hosts but not its own host. The target <code>https://10.0.0.6:9100/metrics</code> is correctly discovered and shows up in prometheus' web ui under the targets.</p>
  <p><strong>However, its status keeps <code>UNKNOWN</code> because it is never successfully scraped.</strong></p>
  <h2>What I tried</h2>
  <p>On <code>10.0.0.6</code> I tried to put <code>node-exporter</code> on the host network:</p>
  <pre><code>  node-exporter:
      network_mode: host
  </code></pre>
  <p>For the <code>prometheus</code> service I tried to add</p>
  <pre><code>  prometheus:
      extra_hosts:
        - &quot;host.docker.internal:host-gateway&quot;
  </code></pre>
  <p>I also ensured that I can curl the metrics successfully (but prometheus cannot) :</p>
  <pre><code>local$ ssh 10.0.0.6
  remote$ curl -u someuser:correctpassword http://10.0.0.6:9100/metrics
  # shows the metrics
  </code></pre>