# InfluxDB + postgres "Error: An internal error has occurred."

**URL:** https://community.influxdata.com/t/influxdb-postgres-error-an-internal-error-has-occurred/18908
**Category:** InfluxDB 2
**Tags:** influxdb, query, flux
**Created:** [March 16, 2021, 1:51pm UTC](https://community.influxdata.com/t/influxdb-postgres-error-an-internal-error-has-occurred/18908 "2021-03-16T13:51:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![eloparco](https://avatars.discourse-cdn.com/v4/letter/e/919ad9/32.png) [@eloparco](https://community.influxdata.com/u/eloparco)
#### Post date: [March 16, 2021, 1:51pm UTC](https://community.influxdata.com/t/influxdb-postgres-error-an-internal-error-has-occurred/18908/1 "2021-03-16T13:51:27Z")

</div>

Hello,  
I’m trying to query a `postgres` db as described in the [docs](https://docs.influxdata.com/influxdb/v2.0/query-data/flux/sql/).

```auto
import "sql"

sql.from(
  driverName: "postgres",
  dataSourceName: "postgresql://my-usr:my-psw@postgres",
  query: "SELECT * FROM metadata"
)

```

where `metadata` is a table I created in `postgres`.  
I also tried specifying the db as `dataSourceName: "postgresql://my-usr:my-psw@postgres/my-db"`, but no luck.

I tried to run the query both using the UI and `influx query` but I always get the generic error:

```auto
Error: An internal error has occurred.

```

In my case, the two services are inside the same network, I’m able to ping `postgres` if I log into influxdb. My docker-compose looks like this:

```auto
version: "3.5"
services:
  influxdb:
    image: influxdb:2.0.4
    container_name: influxdb
    ports:
      - 8086:8086
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=setup
      - DOCKER_INFLUXDB_INIT_USERNAME=my-usr
      - DOCKER_INFLUXDB_INIT_PASSWORD=my-psw
      - DOCKER_INFLUXDB_INIT_ORG=my-org
      - DOCKER_INFLUXDB_INIT_BUCKET=my-bucket
      - DOCKER_INFLUXDB_INIT_RETENTION=53w
      - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-auth-token

  postgres:
    build: postgres
    container_name: postgres
    environment:
      - POSTGRES_DB=my-db
      - POSTGRES_USER=my-usr
      - POSTGRES_PASSWORD=my-psw

```

How can I find additional info about the error and fix it? The generic error message is not giving me any clue.  
Thanks

---

<div class="post-metadata">

### Author: ![eloparco](https://avatars.discourse-cdn.com/v4/letter/e/919ad9/32.png) [@eloparco](https://community.influxdata.com/u/eloparco)
#### Post date: [March 16, 2021, 2:05pm UTC](https://community.influxdata.com/t/influxdb-postgres-error-an-internal-error-has-occurred/18908/2 "2021-03-16T14:05:54Z")

</div>

Found the problem, I’ll share the solution here:

```auto
import "sql"

sql.from(
  driverName: "postgres",
  dataSourceName: "postgresql://my-usr:my-psw@postgres/my-db?sslmode=disable",
  query: "SELECT * FROM metadata"
)

```
