I am working through the book by Koutmos, Tate and Hunleth. I have the sensors collecting data and am trying to set up Postgresql and ecto. I have created the yml file and have Posgresql running with “docker compose up” but I had to use “sudo docker compose up”. I then created the migration with “mix ecto.gen.migration set_up_weather_data_table” and edited the resulting file as per the book (page 49). When I perform the next step which is to run “mix ecto.setup” in the weather_tracker directory I get the following error:
**22:21:17.144 \[error\] Postgrex.Protocol (#PID<0.196.0>) failed to connect: \*\* (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused**
**22:21:17.153 \[error\] :gen_statem #PID<0.196.0> terminating**
**\*\* (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused**
**(db_connection 2.8.1) lib/db_connection/connection.ex:109: DBConnection.Connection.handle_event/4**
**(stdlib 7.2) gen_statem.erl:3743: :gen_statem.loop_state_callback/11**
**(stdlib 7.2) proc_lib.erl:333: :proc_lib.init_p_do_apply/3**
**Process Label: “db_conn_1”**
**Queue: \[internal: {:connect, :init}\]**
**Postponed: [ ]**
**State: Postgrex.Protocol**
**Callback mode: :handle_event_function, state_enter: false**
**22:21:17.162 \[error\] Postgrex.Protocol (#PID<0.202.0>) failed to connect: \*\* (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused**
**22:21:17.162 \[error\] :gen_statem #PID<0.202.0> terminating**
**\*\* (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused**
**(db_connection 2.8.1) lib/db_connection/connection.ex:109: DBConnection.Connection.handle_event/4**
**(stdlib 7.2) gen_statem.erl:3743: :gen_statem.loop_state_callback/11**
**(stdlib 7.2) proc_lib.erl:333: :proc_lib.init_p_do_apply/3**
**Process Label: “db_conn_1”**
**Queue: \[internal: {:connect, :init}\]**
**Postponed: [ ]**
**State: Postgrex.Protocol**
**Callback mode: :handle_event_function, state_enter: false**
**\*\* (Mix) The database for WeatherTracker.Repo couldn’t be created: killed**
I tried running “sudo mix ecto.setup” from the same directory (just in case I need the extra permissions) and it tells me sudo: mix: command not found.
Not sure where to go from here. Any suggestions anyone?
Thanks.






















