I’m trying to create a REST API following this guide: https://www.youtube.com/watch?v=LGY_eILc8Ks&list=PL2Rv8vpZJz4zM3Go3X-dda478p-6xrmEl&index=1.
I’m currently using:
Ubuntu 22.04 LTS
docker 24.0.7
elixir 1.17.2
Following the guide, i create and run a postgres container and try to create a project through the mix command.
I then configure the env.exs file as done in the second video.
At that point i run the mix ecto.create command, which fails with the following message:
`23:53:30.489 [error] Postgrex.Protocol (#PID<0.6242.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
23:53:30.491 [error] :gen_statem #PID<0.6242.0> terminating
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
(db_connection 2.7.0) lib/db_connection/connection.ex:104: DBConnection.Connection.handle_event/4
(stdlib 6.0.1) gen_statem.erl:3115: :gen_statem.loop_state_callback/11
(stdlib 6.0.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Queue: [internal: {:connect, :init}]
Postponed:
State: Postgrex.Protocol
Callback mode: &DBConnection.Connection.handle_event/4, state_enter: false
23:53:30.494 [error] Postgrex.Protocol (#PID<0.6248.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
23:53:30.494 [error] :gen_statem #PID<0.6248.0> terminating
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
(db_connection 2.7.0) lib/db_connection/connection.ex:104: DBConnection.Connection.handle_event/4
(stdlib 6.0.1) gen_statem.erl:3115: :gen_statem.loop_state_callback/11
(stdlib 6.0.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Queue: [internal: {:connect, :init}]
Postponed:
State: Postgrex.Protocol
Callback mode: &DBConnection.Connection.handle_event/4, state_enter: false
** (Mix) The database for Backend24h.Repo couldn’t be created: killed`
As far as i can tell by looking at other posts here this means there are no databases listening on the given port. But i can see and connect to the database by running psql
in bash terminal opened in the container through a docker exec bash
command, so the container is working properly
The videos i’ve linked don’t seem to imply there needs to be anything done besides creating and running the postgres container.
Am i doing something wrong or this linked to the fact that i use linux and not mac, some poor handling of docker, etc. ?