# Failed to obtain a connection with the database Metricbeat

**URL:** <https://discuss.elastic.co/t/failed-to-obtain-a-connection-with-the-database-metricbeat/238249>\
**Category:** Beats\
**Created:** [June 23, 2020, 11:47am UTC](https://discuss.elastic.co/t/failed-to-obtain-a-connection-with-the-database-metricbeat/238249 "2020-06-23T11:47:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![himalc](https://avatars.discourse-cdn.com/v4/letter/h/258eb7/32.png) [@himalc](https://discuss.elastic.co/u/himalc)\
**Post date:** [June 23, 2020, 11:47am UTC](https://discuss.elastic.co/t/failed-to-obtain-a-connection-with-the-database-metricbeat/238249/1 "2020-06-23T11:47:06Z")

</div>

Hi,

I have below issue on metricbeat logs. I have using all applications are in docker containers (metricbeat, postgresql, elasticsearch, kibana). Any help on this?

Error from metricbeat:  
(1) Error  
_INFO module/wrapper.go:252 Error fetching data for metricset postgresql.activity: error in QueryStats: failed to obtain a connection with the database: dial tcp 127.0.0.1:6430: connect: connection refused._

(2) Error  
ERROR pipeline/output.go:100 Failed to connect to backoff(elasticsearch([http://elasticsearch:9200](http://elasticsearch:9200))): Connection marked as failed because the onConnect callback failed: resource 'metricbeat-7.6.2' exists, but it is not an alias.

**metricbeat.yml configurations:**

metricbeat.config.modules:  
path: ${path.config}/modules.d/\*.yml  
reload.enabled: false

processors:  
#- add\_cloud\_metadata: ~

- add\_docker\_metadata: ~

setup.kibana:  
host: "kibana:5601"  
#username: "my\_kibana\_user"  
#password: "YOUR\_PASSWORD"

output.elasticsearch:  
hosts: ["elasticsearch:9200"]

**postgresql.yml (modules.d directory in metricbeat)**

- module: postgresql  
metricsets:
  - database
  - bgwriter
  - activity  
period: 10s  
hosts: ["postgres://localhost:6430?sslmode=disable"]  
username: data (database logging user)  
#password: ""

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 21, 2020, 1:55pm UTC](https://discuss.elastic.co/t/failed-to-obtain-a-connection-with-the-database-metricbeat/238249/2 "2020-07-21T13:55:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
