[discourse] Error: getting db driver for: postgres: failed to connect to database #4316
-
Originally posted by almir on Discourse 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: And I am still constantly getting error: 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. 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 Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
This error is often caused by network isolation between Docker containers. When both Flipt and PostgreSQL are running as separate containers, using localhost in the connection string won't work because localhost inside the Flipt container refers to itself, not your host or the Postgres container. Try running both containers on the same Docker network. For example:
docker network create flipt-net
docker run --name test-postgres --network flipt-net -e POSTGRES_HOST_AUTH_METHOD=trust -d -p 5432:5432 postgres
docker run -it --rm --network flipt-net -p 8080:8080 -e FLIPT_DB_URL="postgres://postgres@test-postgres:5432/postgres?sslmode=disable" flipt/flipt:latest Make sure to use If you still see errors, check the Postgres logs for connection attempts. Also, if you encounter errors about prepared statements or enum types, set Let me know if this helps or if you see a different error after trying these steps. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
Reply from erka on Discourse: Hey @almir When you run Flipt in docker you should use other dns name/ip to access the database. |
Beta Was this translation helpful? Give feedback.
-
Reply from almir on Discourse: Hi, thanks for the help. Solved issue with putting these two dockers (flipt and postgres) in the same network. |
Beta Was this translation helpful? Give feedback.
Reply from erka on Discourse:
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. Tryhost.docker.internal
or172.17.0.2
. For easy start please use flipt/examples/database/postgres at main · flipt-io/flipt · GitHub example withdocker compose