Receiving error when using mix ecto.create

475 Views Asked by At

This is my configuration for the database:

config :hello, Hello.Repo,
  username: "postgres",
  password: "admin",
  hostname: "localhost",
  database: "hello_dev_postgres",
  show_sensitive_data_on_connection_error: true,
  pool_size: 10

config :hello, Hello.MRepo,
  adapter: Tds.Ecto,
  username: "sa",
  password: "server",
  hostname: "localhost",
  instance: "SERVER",
  port: 1433,
  database: "hello_dev_mssql",
  show_sensitive_data_on_connection_error: true,
  pool_size: 10

And this is my two repo:

defmodule Hello.MRepo do
  use Ecto.Repo,
    otp_app: :hello,
    adapter: Ecto.Adapters.Tds
end

defmodule Hello.Repo do
  use Ecto.Repo,
    otp_app: :hello,
    adapter: Ecto.Adapters.Postgres
end

When I run mix ecto.create, I get this error:

16:37:43.867 [error] GenServer #PID<0.309.0> terminating
** (Tds.Error) tcp connect: econnrefused
(db_connection 2.4.2) lib/db_connection/connection.ex:100: DBConnection.Connection.connect/2
(connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
(stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Tds.Protocol
(Mix) The database for Hello.MRepo couldn't be created: killed

1

There are 1 best solutions below

1
On

Have you enabled TCP in your database configuration file?

There is a similar post on the elixirforum where someone had the same problem as you and enabling TCP in one of the configuration file helped them.