skip to Main Content

I keep getting this error when I try to connect:
Post "https://localhost:1235/api/v1/query": dial tcp [::1]:1235: connect: connection refused – There was an error returned querying the Prometheus API.

My Prometheus and Grafana is running on a virtual server, but I am using SSH tunneling to connect to Grafana on localhost:1234 and to Prometheus on localhost:1235 since I dont have more ports available on my server. I am able to access both sites when looking them up also Prometheus aswell as Grafana are both running and there is no other error. But I cannot connect my data from Prometheus to Grafana.
What am I missing?

My prometheus.yml in my virtual server:

global:
scrape_interval: 15s

scrape_configs:

  • job_name: ‘backend’
    static_configs:

    • targets: [‘backend:1433’]
  • job_name: ‘nginx’
    static_configs:

    • targets: [‘nginx:80’]
  • job_name: ‘nginx_exporter’
    static_configs:

    • targets: [‘nginx_exporter:9113’]
  • job_name: ‘cadvisor’
    scrape_interval: 5s
    static_configs:

    • targets: [‘cadvisor:8080’]

I have my API endpoints in my backend and using nginx and nginx exporter. Also using docker containers.

I have tried 127.0.0.1 instead of localhost.
I have tried 9091 instead – since this is where my prometheus is listening in my virtuel server.
I have tried prometheus in url.
I can see that prometheus is collecting data and everything else is working. I have tried restarting and also tried using the docker url also that i seen somewhere else.
I have looked up otherrs having same problem, but none of their answers have solved mine.

2

Answers


  1. Chosen as BEST ANSWER

    Yes i deployed it in docker and i tried using host.docker.internal, it says the same thing.


  2. Do you deploy grafana and prometheus in docker? You need use host.docker.internal instead of 127.0.0.1.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search