# Error fetching data for metricset postgresql.activity: error in QueryStats: failed to obtain a connection with the database: pq: SSL is not enabled on the server","service.name":"metricbeat","ecs.version":"1.6.0"}

**URL:** <https://discuss.elastic.co/t/error-fetching-data-for-metricset-postgresql-activity-error-in-querystats-failed-to-obtain-a-connection-with-the-database-pq-ssl-is-not-enabled-on-the-server-service-name-metricbeat-ecs-version-1-6-0/344996>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [October 13, 2023, 11:50am UTC](https://discuss.elastic.co/t/error-fetching-data-for-metricset-postgresql-activity-error-in-querystats-failed-to-obtain-a-connection-with-the-database-pq-ssl-is-not-enabled-on-the-server-service-name-metricbeat-ecs-version-1-6-0/344996 "2023-10-13T11:50:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![veerendra\_pulapa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/veerendra_pulapa/32/126514_2.png) [@veerendra\_pulapa](https://discuss.elastic.co/u/veerendra_pulapa)\
**Post date:** [October 13, 2023, 11:50am UTC](https://discuss.elastic.co/t/error-fetching-data-for-metricset-postgresql-activity-error-in-querystats-failed-to-obtain-a-connection-with-the-database-pq-ssl-is-not-enabled-on-the-server-service-name-metricbeat-ecs-version-1-6-0/344996/1 "2023-10-13T11:50:29Z")

</div>

Dear Team,

I'm encountering SSL errors when trying to connect Metricbeat to my PostgreSQL database. Here are the details:

- Error Message:  
{"log.level":"error","@timestamp":"2023-10-13T11:45:38.996Z","log.origin":{"file.name":"module/wrapper.go","file.line":256},"message":"Error fetching data for metricset postgresql.database: error in QueryStats: failed to obtain a connection with the database: pq: SSL is not enabled on the server","service.name":"metricbeat","ecs.version":"1.6.0"}  
{"log.level":"error","@timestamp":"2023-10-13T11:45:38.996Z","log.origin":{"file.name":"module/wrapper.go","file.line":256},"message":"Error fetching data for metricset postgresql.bgwriter: error in QueryStats: failed to obtain a connection with the database: pq: SSL is not enabled on the server","service.name":"metricbeat","ecs.version":"1.6.0"}  
{"log.level":"error","@timestamp":"2023-10-13T11:45:38.996Z","log.origin":{"file.name":"module/wrapper.go","file.line":256},"message":"Error fetching data for metricset postgresql.activity: error in QueryStats: failed to obtain a connection with the database: pq: SSL is not enabled on the server","service.name":"metricbeat","ecs.version":"1.6.0"}  
{"log.level":"error","@timestamp":"2023-10-13T11:45:38.996Z","log.origin":{"file.name":"module/wrapper.go","file.line":256},"message":"Error fetching data for metricset postgresql.statement: QueryStats: failed to obtain a connection with the database: pq: SSL is not enabled on the server","service.name":"metricbeat","ecs.version":"1.6.0"}

- Environment:

- postgresql.yml Configuration:

- module: postgresql  
enabled: true  
metricsets:

- Steps Taken:

- Questions:

- Postgresql SSL is off

- Expectations:

- Contact Information:

Thank you for your assistance.

---

<div class="post-metadata">

**Author:** ![Agi\_K\_Thomas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/agi_k_thomas/32/130842_2.png) [@Agi\_K\_Thomas](https://discuss.elastic.co/u/Agi_K_Thomas)\
**Post date:** [October 24, 2023, 12:59pm UTC](https://discuss.elastic.co/t/error-fetching-data-for-metricset-postgresql-activity-error-in-querystats-failed-to-obtain-a-connection-with-the-database-pq-ssl-is-not-enabled-on-the-server-service-name-metricbeat-ecs-version-1-6-0/344996/2 "2023-10-24T12:59:45Z")

</div>

Could you please try as following

postgres://metricbeatuser:metricbeatuser@localhost:5432/postgres?sslmode=disable

---

<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:** [November 21, 2023, 2:59pm UTC](https://discuss.elastic.co/t/error-fetching-data-for-metricset-postgresql-activity-error-in-querystats-failed-to-obtain-a-connection-with-the-database-pq-ssl-is-not-enabled-on-the-server-service-name-metricbeat-ecs-version-1-6-0/344996/3 "2023-11-21T14:59:55Z")

</div>

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