Error: getting db driver for: postgres: failed to connect to database

Hi I would appreciate if someone can help me with issue that I am having.

So when I try to run locally flipt docker with command I am getting Error: getting db driver for: postgres: failed to connect to database:

docker run -it --rm -p 8080:8080 -e FLIPT_DB_URL=“postgres://postgres@localhost:5432/postgres” flipt/flipt:latest

Tried also in this way:
docker run --rm -p 8080:8080 -p 9000:9000 -t -e FLIPT_DB_PROTOCOL=“postgres” -e FLIPT_DB_HOST=“localhost” -e FLIPT_DB_PORT=5432 -e FLIPT_DB_NAME=“postgres” -e FLIPT_DB_USER=“postgres” docker.flipt.io/flipt/flipt:latest

And I am still constantly getting error:
You are currently running the latest version of Flipt [v1.56.0]!
Error: getting db driver for: postgres: failed to connect to database

PostgreSQL database that I am trying to connect is started also as docker on my local machine and I can connect easy with some DB tool.
Tried also to create flipt database on docker Postgresql and to use that in connection parameters but it still doesn’t work.

Also tried option to start Postgresql without need for password using command: docker run --name test-postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d -p 5432:5432 postgres
but still I am getting same error.

Any help would be appreciated.

Hey @almir

When you run Flipt in docker you should use other dns name/ip to access the database. localhost is not an option here. Try host.docker.internal or 172.17.0.2. For easy start please use flipt/examples/database/postgres at main · flipt-io/flipt · GitHub example with docker compose

1 Like

Hi, thanks for the help.
Solved issue with putting these two dockers (flipt and postgres) in the same network.