2
votes

I'm following the guide to setting up Phoenix here

This is my dev.exs file:

use Mix.Config

# Configure your database
config :api, Api.Repo,
  username: <username>,
  password: <password>,
  database: <dbname>,
  hostname: "localhost",
  show_sensitive_data_on_connection_error: true,
  pool_size: 10,
  timeout: 120_000,
  queue_target: 5000,
  queue_interval: 100_000

# For development, we disable any cache and enable
# debugging and code reloading.
#
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with webpack to recompile .js and .css sources.
config :api, ApiWeb.Endpoint,
  http: [port: 4000],
  debug_errors: true,
  code_reloader: true,
  check_origin: false,
  watchers: [
    node: [
      "node_modules/webpack/bin/webpack.js",
      "--mode",
      "development",
      "--watch-stdin",
      cd: Path.expand("../assets", __DIR__)
    ]
  ]

When I run

ecto.create

I get the following error:

The database for Api.Repo couldn't be created: connection not available and request was dropped from queue after 2994ms. You can configure how long requests wait in the queue using :queue_target and :queue_interval. See DBConnection.start_link/2 for more information

To my knowledge I'm already using queue_target and queue_interval. What am I doing wrong?

My database is running. I'm able to run

psql -U <username>

and access a psql console.

postgres-# \conninfo
You are connected to database postgres as user <username> via socket in "/var/run/postgresql" at port "5432".
1
What is your Elixir and Ecto version? - Mathieu Kerjouan

1 Answers

1
votes

My guess is that by specifying "hostname" you're trying to connect via TCP/IP, while in your successful connection example you are connecting via UNIX socket. I think you should specify:

config :api, Api.Repo,
  socket_dir: "/var/run/postgresql",
  ...

to setup the connection via UNIX socket in ecto.