elixir-ecto / ecto

A toolkit for data mapping and language integrated query.
https://hexdocs.pm/ecto
Apache License 2.0
6.14k stars 1.43k forks source link

can't migrate repo on postgres 9.2 with trusted auth #293

Closed j-mcnally closed 9 years ago

j-mcnally commented 9 years ago
** (exit) exited in: :gen_server.call(#PID<0.181.0>, {:query, "CREATE TABLE IF NOT EXISTS schema_migrations (id serial primary key, version bigint)", [], [timeout: 5000]}, 5000)
    ** (EXIT) exited in: :gen_server.call(#PID<0.186.0>, {:connect, [port: 5432, encoder: #Function<17.12881986/3 in Ecto.Adapters.Postgres.prepare_start/2>, decoder: #Function<16.12881986/4 in Ecto.Adapters.Postgres.prepare_start/2>, formatter: #Function<15.12881986/1 in Ecto.Adapters.Postgres.prepare_start/2>, username: "webapp", hostname: "localhost", database: "struct"]}, :infinity)
        ** (EXIT) an exception was raised:
            ** (ArgumentError) argument error
                :erlang.iolist_to_binary([nil, "webapp"])
                (crypto) crypto.erl:223: :crypto.hash/2
                (postgrex) lib/postgrex/connection.ex:519: Postgrex.Connection.message/3
                (postgrex) lib/postgrex/connection.ex:491: Postgrex.Connection.new_data/2
                (postgrex) lib/postgrex/connection.ex:401: Postgrex.Connection.handle_info/2
                (stdlib) gen_server.erl:599: :gen_server.handle_msg/5
                (stdlib) proc_lib.erl:239: :proc_lib.init_p_do_apply/3
    (stdlib) gen_server.erl:190: :gen_server.call/3
    (ecto) lib/ecto/adapters/postgres/worker.ex:18: Ecto.Adapters.Postgres.Worker.query!/4
    (ecto) lib/ecto/adapters/postgres.ex:353: Ecto.Adapters.Postgres.use_worker/3
    (ecto) lib/ecto/adapters/postgres.ex:514: Ecto.Adapters.Postgres.migrated_versions/1
    (ecto) lib/ecto/migrator.ex:92: Ecto.Migrator.pending_in_direction/3
    (ecto) lib/ecto/migrator.ex:87: Ecto.Migrator.run_all/3
    (mix) lib/mix/cli.ex:55: Mix.CLI.run_task/2

04:59:20.401 [error] GenServer #PID<0.186.0> terminating
Last message: {:tcp, #Port<0.6186>, <<82, 0, 0, 0, 12, 0, 0, 0, 5, 188, 234, 102, 118>>}
State: %{backend_key: nil, bootstrap: false, opts: [port: 5432, encoder: #Function<17.12881986/3 in Ecto.Adapters.Postgres.prepare_start/2>, decoder: #Function<16.12881986/4 in Ecto.Adapters.Postgres.prepare_start/2>, formatter: #Function<15.12881986/1 in Ecto.Adapters.Postgres.prepare_start/2>, username: "webapp", hostname: "localhost", database: "struct"], parameters: %{}, portal: nil, queue: {[{{:connect, [port: 5432, encoder: #Function<17.12881986/3 in Ecto.Adapters.Postgres.prepare_start/2>, decoder: #Function<16.12881986/4 in Ecto.Adapters.Postgres.prepare_start/2>, formatter: #Function<15.12881986/1 in Ecto.Adapters.Postgres.prepare_start/2>, username: "webapp", hostname: "localhost", database: "struct"]}, {#PID<0.181.0>, #Reference<0.0.0.1954>}, nil}], []}, rows: [], sock: {:gen_tcp, #Port<0.6186>}, state: :auth, statement: nil, tail: "", transactions: 0, types: :types_removed}
** (exit) an exception was raised:
    ** (ArgumentError) argument error
        :erlang.iolist_to_binary([nil, "webapp"])
        (crypto) crypto.erl:223: :crypto.hash/2
        (postgrex) lib/postgrex/connection.ex:519: Postgrex.Connection.message/3
        (postgrex) lib/postgrex/connection.ex:491: Postgrex.Connection.new_data/2
        (postgrex) lib/postgrex/connection.ex:401: Postgrex.Connection.handle_info/2
        (stdlib) gen_server.erl:599: :gen_server.handle_msg/5
        (stdlib) proc_lib.erl:239: :proc_lib.init_p_do_apply/3
j-mcnally commented 9 years ago

i was able to create the db

ericmj commented 9 years ago

This error suggests that trusted authentication is not set up correctly. It fails in the code path used when postgres asks for md5 auth with username+password.

j-mcnally commented 9 years ago

hmm odd... ill look into it, probably a problem with my ecto url then.

ericmj commented 9 years ago

You may want to check that your pg_hba.conf file is set up correctly for trusted auth (if you haven't already done that).

j-mcnally commented 9 years ago

i am under the impression im using the wrong form between 127.0.0.1 and localhost and how they resolve in relation to ipv6

josevalim commented 9 years ago

I think we should at least have a less cryptic error message here. @ericmj is it possible?

ericmj commented 9 years ago

@josevalim It can be improved. Opened an issue on postgrex.