Ecto Remote DB Connection Issue

I have 2 google cloud instances and I would like to connect both in DEV envirorment:

  • phoenix instance with devs.exs configuration:
  • mysql instance (Internal IP:
# Configure your database
config :hello, Hello.Repo,
  adapter: Ecto.Adapters.MySQL,
  username: "root",
  password: "root",
  database: "hello_dev",
  hostname: "",
  pool_size: 10

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

** (Mix) The database for Hello.Repo couldn't be created: exited in:<0.303.0>, {:checkout, #Reference<0.1029740764.2228486145.82068>, true, 15000}, 5000)
    ** (EXIT) time out

20:43:21.008 [error] Task #PID<0.302.0> started from #PID<0.74.0> terminating
** (stop) exited in:<0.303.0>, {:checkout, #Reference<0.1029740764.2228486145.82068>, true, 15000}, 5000)
    ** (EXIT) time out
    (db_connection) lib/db_connection/connection.ex:54: DBConnection.Connection.checkout/2
    (db_connection) lib/db_connection.ex:928: DBConnection.checkout/2
    (db_connection) lib/db_connection.ex:750:
    (db_connection) lib/db_connection.ex:1141: DBConnection.run_meter/3
    (db_connection) lib/db_connection.ex:592: DBConnection.prepare_execute/4
    lib/ecto/adapters/mysql/connection.ex:22: Ecto.Adapters.MySQL.Connection.execute/4
    lib/ecto/adapters/mysql.ex:286: anonymous fn/2 in Ecto.Adapters.MySQL.run_query/2
    (elixir) lib/task/supervised.ex:88: Task.Supervised.do_apply/2
    (elixir) lib/task/supervised.ex:38: Task.Supervised.reply/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Function: #Function<9.85109569/0 in Ecto.Adapters.MySQL.run_query/2>
    Args: []

What should I do?

Do you mean dev.exs?

If this is in your dev.exs file it looks correct from a syntax standpoint.

Are you trying to connect from a machine inside your Google Cloud network? If not, you need to use an external/public IP address configure Google Cloud to allow external IPs on the port your MySQL instance is at. The internal address is only available from machines on the same Google Cloud network.

If you feel like all of these things are correct, try connecting with pgAdmin, psql, or another client outside of elixir.