cphoniball / timer

Phoenix app to learn me some Elixir
0 stars 0 forks source link

Can't seem to get phoenix to connect to the db? #1

Open erlandsona opened 6 years ago

erlandsona commented 6 years ago

I've tried changing the host config in apps/api/config/dev.exs to "db", "localhost", "0.0.0.0", no avail.

Thoughts?

erlandsona commented 6 years ago

More context

phoenix_1      | All dependencies up to date
phoenix_1      | Compiling 36 files (.ex)
phoenix_1      | warning: unused alias Guardian
phoenix_1      |   lib/timer_web/controllers/time_entry_controller.ex:5
phoenix_1      |
phoenix_1      | Generated timer app
phoenix_1      | [error] Postgrex.Protocol (#PID<0.487.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | [error] Could not retrieve migrated versions. This error usually happens due to the following:
phoenix_1      |
phoenix_1      |   * The database does not exist
phoenix_1      |   * The "schema_migrations" table, which Ecto uses for managing
phoenix_1      |     migrations, was defined by another library
phoenix_1      |
phoenix_1      | To fix the first issue, run "mix ecto.create".
phoenix_1      |
phoenix_1      | To address the second, you can run "mix ecto.drop" followed by
phoenix_1      | "mix ecto.create". Alternatively you may configure Ecto to use
phoenix_1      | another table for managing migrations:
phoenix_1      |
phoenix_1      |     config :timer, Timer.Repo,
phoenix_1      |       migration_source: "some_other_table_for_schema_migrations"
phoenix_1      |
phoenix_1      | The full error report is shown below.
phoenix_1      |
phoenix_1      | ** (DBConnection.ConnectionError) connection not available because of disconnection
phoenix_1      |     (elixir) lib/keyword.ex:504: Keyword.delete_key/3
phoenix_1      |     (elixir) lib/keyword.ex:501: Keyword.delete_key/3
phoenix_1      |     (elixir) lib/keyword.ex:501: Keyword.delete_key/3
phoenix_1      |     (elixir) lib/keyword.ex:493: Keyword.put/3
phoenix_1      |     lib/timer/repo.ex:9: Timer.Repo.init/2
phoenix_1      |     (ecto) lib/ecto/repo/supervisor.ex:24: Ecto.Repo.Supervisor.runtime_config/4
phoenix_1      |     lib/timer/repo.ex:2: Timer.Repo.config/0
phoenix_1      |     (ecto) lib/ecto/migrator.ex:316: Ecto.Migrator.verbose_schema_migration/3
phoenix_1      |     (ecto) lib/ecto/migrator.ex:157: Ecto.Migrator.run/4
phoenix_1      |     (ecto) lib/mix/tasks/ecto.migrate.ex:83: anonymous fn/4 in Mix.Tasks.Ecto.Migrate.run/2
phoenix_1      |     (elixir) lib/enum.ex:737: Enum."-each/2-lists^foreach/1-0-"/2
phoenix_1      |     (elixir) lib/enum.ex:737: Enum.each/2
phoenix_1      |     (mix) lib/mix/task.ex:314: Mix.Task.run_task/3
phoenix_1      |     (mix) lib/mix/cli.ex:80: Mix.CLI.run_task/2
phoenix_1      |     (elixir) lib/code.ex:677: Code.require_file/2
phoenix_1      | [error] GenServer Timer.Repo terminating
phoenix_1      | ** (DBConnection.ConnectionError) connection not available because of disconnection
phoenix_1      |     (elixir) lib/keyword.ex:504: Keyword.delete_key/3
phoenix_1      |     (elixir) lib/keyword.ex:501: Keyword.delete_key/3
phoenix_1      |     (elixir) lib/keyword.ex:501: Keyword.delete_key/3
phoenix_1      |     (elixir) lib/keyword.ex:493: Keyword.put/3
phoenix_1      |     lib/timer/repo.ex:9: Timer.Repo.init/2
phoenix_1      |     (ecto) lib/ecto/repo/supervisor.ex:24: Ecto.Repo.Supervisor.runtime_config/4
phoenix_1      |     lib/timer/repo.ex:2: Timer.Repo.config/0
phoenix_1      |     (ecto) lib/ecto/migrator.ex:316: Ecto.Migrator.verbose_schema_migration/3
phoenix_1      |     (ecto) lib/ecto/migrator.ex:157: Ecto.Migrator.run/4
phoenix_1      |     (ecto) lib/mix/tasks/ecto.migrate.ex:83: anonymous fn/4 in Mix.Tasks.Ecto.Migrate.run/2
phoenix_1      |     (elixir) lib/enum.ex:737: Enum."-each/2-lists^foreach/1-0-"/2
phoenix_1      |     (elixir) lib/enum.ex:737: Enum.each/2
phoenix_1      |     (mix) lib/mix/task.ex:314: Mix.Task.run_task/3
phoenix_1      |     (mix) lib/mix/cli.ex:80: Mix.CLI.run_task/2
phoenix_1      |     (elixir) src/elixir_compiler.erl:85: :elixir_compiler.dispatch/6
phoenix_1      |     (elixir) src/elixir_lexical.erl:18: :elixir_lexical.run/3
phoenix_1      |     (elixir) src/elixir_compiler.erl:27: :elixir_compiler.quoted/3
phoenix_1      |     (elixir) lib/code.ex:677: Code.require_file/2
phoenix_1      |     (elixir) lib/kernel/cli.ex:504: Kernel.CLI.wrapper/1
phoenix_1      |     (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
phoenix_1      | Last message: {:EXIT, #PID<0.74.0>, {%DBConnection.ConnectionError{message: "connection not available because of disconnection"}, [{Keyword, :delete_key, 3, [file: 'lib/keyword.ex', line: 504]}, {Keyword, :delete_key, 3, [file: 'lib/keyword.ex', line: 501]}, {Keyword, :delete_key, 3, [file: 'lib/keyword.ex', line: 501]}, {Keyword, :put, 3, [file: 'lib/keyword.ex', line: 493]}, {Timer.Repo, :init, 2, [file: 'lib/timer/repo.ex', line: 9]}, {Ecto.Repo.Supervisor, :runtime_config, 4, [file: 'lib/ecto/repo/supervisor.ex', line: 24]}, {Timer.Repo, :config, 0, [file: 'lib/timer/repo.ex', line: 2]}, {Ecto.Migrator, :verbose_schema_migration, 3, [file: 'lib/ecto/migrator.ex', line: 316]}, {Ecto.Migrator, :run, 4, [file: 'lib/ecto/migrator.ex', line: 157]}, {Mix.Tasks.Ecto.Migrate, :"-run/2-fun-1-", 4, [file: 'lib/mix/tasks/ecto.migrate.ex', line: 83]}, {Enum, :"-each/2-lists^foreach/1-0-", 2, [file: 'lib/enum.ex', line: 737]}, {Enum, :each, 2, [file: 'lib/enum.ex', line: 737]}, {Mix.Task, :run_task, 3, [file: 'lib/mix/task.ex', line: 314]}, {Mix.CLI, :run_task, 2, [file: 'lib/mix/cli.ex', line: 80]}, {:elixir_compiler, :dispatch, 6, [file: 'src/elixir_compiler.erl', line: 85]}, {:elixir_lexical, :run, 3, [file: 'src/elixir_lexical.erl', line: 18]}, {:elixir_compiler, :quoted, 3, [file: 'src/elixir_compiler.erl', line: 27]}, {Code, :require_file, 2, [file: 'lib/code.ex', line: 677]}, {Kernel.CLI, :wrapper, 1, [file: 'lib/kernel/cli.ex', line: 504]}, {Enum, :"-map/2-lists^map/1-0-", 2, [file: 'lib/enum.ex', line: 1294]}]}}
phoenix_1      | State: {:state, {:local, Timer.Repo}, :one_for_one, [{:child, #PID<0.485.0>, DBConnection.Poolboy, {:poolboy, :start_link, [[name: {:local, Timer.Repo.Pool}, strategy: :fifo, size: 1, max_overflow: 0, worker_module: DBConnection.Poolboy.Worker], {Postgrex.Protocol, [types: Ecto.Adapters.Postgres.TypeModule, name: Timer.Repo.Pool, otp_app: :timer, repo: Timer.Repo, timeout: 15000, pool_timeout: 5000, adapter: Ecto.Adapters.Postgres, username: "postgres", password: "root", database: "timer", hostname: "localhost", port: 6432, pool_size: 1, pool: DBConnection.Poolboy]}]}, :permanent, 5000, :worker, [:poolboy]}], :undefined, 3, 5, [], 0, Ecto.Repo.Supervisor, {Timer.Repo, :timer, Ecto.Adapters.Postgres, [pool_size: 1]}}
phoenix_1      | [error] Postgrex.Protocol (#PID<0.319.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | [error] Postgrex.Protocol (#PID<0.322.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | [error] Postgrex.Protocol (#PID<0.315.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | [error] Postgrex.Protocol (#PID<0.320.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | [error] Postgrex.Protocol (#PID<0.321.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | [error] Postgrex.Protocol (#PID<0.317.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | [error] Postgrex.Protocol (#PID<0.314.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | [error] Postgrex.Protocol (#PID<0.318.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | [error] Postgrex.Protocol (#PID<0.316.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | [error] Postgrex.Protocol (#PID<0.313.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:6432): connection refused - :econnrefused
phoenix_1      | ** (DBConnection.ConnectionError) connection not available because of disconnection
phoenix_1      |     (db_connection) lib/db_connection.ex:934: DBConnection.checkout/2
phoenix_1      |     (db_connection) lib/db_connection.ex:750: DBConnection.run/3
phoenix_1      |     (db_connection) lib/db_connection.ex:798: DBConnection.transaction/3
phoenix_1      |     (ecto) lib/ecto/repo/schema.ex:125: Ecto.Repo.Schema.insert!/4
phoenix_1      |     priv/repo/seeds.exs:15: (file)
phoenix_1      |     (elixir) lib/code.ex:677: Code.require_file/2
phoenix_1      |     (mix) lib/mix/tasks/run.ex:136: Mix.Tasks.Run.run/5
phoenix_1      |     (mix) lib/mix/tasks/run.ex:76: Mix.Tasks.Run.run/1
phoenix_1      |     (mix) lib/mix/task.ex:314: Mix.Task.run_task/3
phoenix_1      |     (mix) lib/mix/cli.ex:80: Mix.CLI.run_task/2
phoenix_1      |     (elixir) lib/code.ex:677: Code.require_file/2
cphoniball commented 6 years ago

I updated that to run Phoenix locally and forgot about the Docker-only setup. Updated the Phoenix app so we can use environment variables at runtime using Confex, and updated the docker-compose.yml file to set appropriate database environment variables if you are using Docker. Try pulling the latest from develop and see if that resolves the issue for you.

Also updated readme instructions to include how to develop by running Phoenix/Webpack locally.