mix ecto.create connection refused

杀马特。学长 韩版系。学妹 提交于 2019-12-12 04:57:19

问题


I received this error when trying to run mix ecto.create:

13:27:47.442 [error] GenServer #PID<0.3189.0> terminating ** (DBConnection.ConnectionError) tcp connect (localhost:5432):connection refused - :econnrefused (db_connection) lib/db_connection/connection.ex:148:DBConnection.Connection.connect/2 (connection) lib/connection.ex:622: Connection.enter_connect/5 (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3 Last message: nil State: Postgrex.Protocol ** (Mix) The database for Hello.Repo couldn't be created: an exception was raised: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused (db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2 (connection) lib/connection.ex:622: Connection.enter_connect/5 (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3


回答1:


You must make sure that the postgresql server is running. The easiest way to this on mac OS X is through brew.

Run the command brew services start postgresql and you should see the result:

==> Successfully started postgresql (label: homebrew.mxcl.postgresql)




回答2:


do you have Postgres locally installed in your machine? This error mostly comes when you don't have Postgres installed.

Use these commands to install Postgres

sudo apt-get update sudo apt-get install postgresql postgresql-contrib



来源:https://stackoverflow.com/questions/44358515/mix-ecto-create-connection-refused

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!