Help debugging Postgrex.Protocol errors

I’m trying to dockerize my Elixir 1.9.1 app. It uses Plug.Router to access my Postgres database. When I bring my app up with “docker-compose up”, I get the following error:

izendor_server_container | 20:33:23.860 [error] Postgrex.Protocol (#PID<0.1277.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused

Can anyone suggest how I can debug this? Are there any logs where I might get some information on why the database connection is being refused.

My docker.compose.yml file is:

version: '3.5'

    image: izendor_db_image
    container_name: izendor_db_container
      - "5432:5432"
      - /Users/charlesirvine/src/evrsity/evrsity-db/volumes/postgres:/var/lib/postgresql/data
      - izendor_db
    image: izendor_server_image
    container_name: izendor_server_container
      - "4000:4000" # In our .env file above, we chose port 4000
      - config/docker.env

The database service seems to be coming up ok:

izendor_db_container | 2019-08-23 20:33:22.715 UTC [1] LOG:  listening on IPv4 address "", port 5432
izendor_db_container | 2019-08-23 20:33:22.715 UTC [1] LOG:  listening on IPv6 address "::", port 5432
izendor_db_container | 2019-08-23 20:33:22.717 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
izendor_db_container | 2019-08-23 20:33:22.797 UTC [24] LOG:  database system was shut down at 2019-08-23 20:31:43 UTC
izendor_db_container | 2019-08-23 20:33:22.820 UTC [1] LOG:  database system is ready to accept connections

In case any other newbie has the same problem - I needed to add my database hostname, as specified in my docker-compose.yml file, to the config/config.exs file:

use Mix.Config

config :izendor, Izendor.Repo,
  database: "XXXXXX",
  username: "XXXXXX",
  hostname: "izendor_db",
  show_sensitive_data_on_connection_error: true

config :izendor, :ecto_repos, [Izendor.Repo]