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'
services:
izendor_db:
image: izendor_db_image
container_name: izendor_db_container
ports:
- "5432:5432"
volumes:
- /Users/charlesirvine/src/evrsity/evrsity-db/volumes/postgres:/var/lib/postgresql/data
izendor_server:
depends_on:
- izendor_db
image: izendor_server_image
container_name: izendor_server_container
ports:
- "4000:4000" # In our .env file above, we chose port 4000
env_file:
- 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 "0.0.0.0", 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