Cannot connect to Prometheus Datasource

I get this error when I try to add a Prometheus data source to grafana.

Error reading Prometheus: Post "http://localhost:9090/api/v1/query": dial tcp 127.0.0.1:9090: connect: connection refused

Can someone please help?

Hi @swamht1929,

Welcome to the :grafana: community support forums !!

We are excited that you joined our OSS community. Please read about some of the FAQs in the community :slight_smile:

Are you running Prometheus and Grafana in a Docker, Kubernetes or any other environment?

i get the same error too “Error reading Prometheus: Get “http://localhost:9090/api/v1/query?query=1%2B1&time=1686043455.756”: dial tcp 127.0.0.1:9090: connect: connection refused”