title: Getting error "Get http://localhost:9443/metrics: dial tcp 127.0.0.1:9443: connect: connection refused"
body: <p>I'm trying to configure Prometheus and Grafana with my Hyperledger fabric v1.4 network to analyze the peer and chaincode mertics. I've mapped peer container's port <code>9443</code> to my host machine's port <code>9443</code> after following this <a href="https://hyperledger-fabric.readthedocs.io/en/latest/operations_service.html#peer" rel="noreferrer">documentation</a>. I've also changed the <code>provider</code> entry to <code>prometheus</code> under <code>metrics</code> section in <code>core.yml</code> of peer. I've configured prometheus and grafana in <code>docker-compose.yml</code> in the following way.</p>
  
  <pre><code>  prometheus:
      image: prom/prometheus:v2.6.1
      container_name: prometheus
      volumes:
      - ./prometheus/:/etc/prometheus/
      - prometheus_data:/prometheus
      command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/etc/prometheus/console_libraries'
      - '--web.console.templates=/etc/prometheus/consoles'
      - '--storage.tsdb.retention=200h'
      - '--web.enable-lifecycle'
      restart: unless-stopped
      ports:
      - 9090:9090
      networks:
      - basic
      labels:
      org.label-schema.group: "monitoring"
  
    grafana:
      image: grafana/grafana:5.4.3
      container_name: grafana
      volumes:
      - grafana_data:/var/lib/grafana
      - ./grafana/datasources:/etc/grafana/datasources
      - ./grafana/dashboards:/etc/grafana/dashboards
      - ./grafana/setup.sh:/setup.sh
      entrypoint: /setup.sh
      environment:
      - GF_SECURITY_ADMIN_USER={ADMIN_USER}
      - GF_SECURITY_ADMIN_PASSWORD={ADMIN_PASS}
      - GF_USERS_ALLOW_SIGN_UP=false
      restart: unless-stopped
      ports:
      - 3000:3000
      networks:
      - basic
      labels:
      org.label-schema.group: "monitoring"
  </code></pre>
  
  <p>When I <code>curl 0.0.0.0:9443/metrics</code> on my remote centos machine, I get all the list of metrics. However, when I run Prometheus with the above configuration, it throws the error <code>Get http://localhost:9443/metrics: dial tcp 127.0.0.1:9443: connect: connection refused</code>. This is what my <code>prometheus.yml</code> looks like.</p>
  
  <pre><code>global:
    scrape_interval:     15s
    evaluation_interval: 15s
  
  scrape_configs:
    - job_name: 'prometheus'
      scrape_interval: 10s
      static_configs:
        - targets: ['localhost:9090']
  
    - job_name: 'peer_metrics'
      scrape_interval: 10s
      static_configs:
        - targets: ['localhost:9443']
  </code></pre>
  
  <p>Even, when I go to endpoint <code>http://localhost:9443/metrics</code> in my browser, I get all the metrics. What am I doing wrong here. How come Prometheus metrics are being shown on its interface and not peer's?</p>