I can't connect to the default Postgres image from a separate docker service running node & Sequelize.
I'm assuming that my setup of the container is not correct and also perhaps my connection info is incorrect too because I when I run docker-compose --build I cannot connect to my database using the connection info:
Host: 0.0.0.0
Port: 5432
User: guy
Password: password
Database: engauge
The error message is
Unable to connect to the database: { SequelizeConnectionRefusedError: connect ECONNREFUSED 0.0.0.0:5432
at /usr/src/app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:98:20
I am running with a YML file that looks like this
version: '2' # specify docker-compose version
# Define the services/containers to be run
services:
web: # name of the first service
build: . # specify the directory of the Dockerfile
ports:
- "3000:3000" # specify port forewarding
links:
- database
database: # name of the third service
image: postgres # specify image to build container from
ports:
- "5432:5432" # specify port forewarding
environment:
- POSTGRES_USER:'guy'
- POSTGRES_PASSWORD:'password'
- POSTGRES_DB:'engauge'
And my connection from within my web service looks like this
const sequelize = new Sequelize('postgresql://guy:[email protected]/engauge');