Hi,
I am new to Elixir. I am trying to run the Sample Music application provided by Ecto Programming book. When I am running the “mix ecto.create” command. I am getting the below error.
7:46:12.441 [error] GenServer #PID<0.174.0> terminating
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
(db_connection) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for Friends.Repo couldn’t be created: killed
The error you posted looks like there is no database running where the config would expect it. Please make sure the database server is available at the configured location (or fix configuration).
Thanks for prompt response!!
I am runing the postgres using docker in the same port 5432. Do I need to do anything else? It would be good if you provide me some reference.
I am simply running the “docker run postges”, which run the postgres in the local host. But it’s not running in same container. Let me check. Thanks for Lead.
I actually just ran into this same error and was able to resolve the issue with the following:
Run postgres -D /usr/local/var/postgres
Copy the process number after PID in parenthesis below if you see a similar output:
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 68449) running in data directory "/usr/local/var/postgres"?
Run kill -9 PID replacing PID with the process number from above
Note that I experienced this issue after my Macbook Pro crashed after I went to bed last night. After running the above commands you should be able to run mix ecto.create afterwards and not experience the same error.