ノードを実行している別のドッカーサービスからデフォルトのPostgresイメージに接続できません& Sequelize。DockerでPostgresコンテナに接続できませんSequelizeから作成
Host: 0.0.0.0
Port: 5432
User: guy
Password: password
Database: engauge
:
私は、コンテナの私の設定が間違っていると私はdocker-compose --build
を実行したとき、私は、接続情報を使用して、私のデータベースに接続できないためにも、おそらく私の接続情報があまりにも間違っていると仮定しています私はこの
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'
012のように見えるYMLファイルを実行しています
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
エラーメッセージがあります
そして、私のWebサービスの中から、私の接続がこの
const sequelize = new Sequelize('postgresql://guy:[email protected]/engauge');
あなたは0.0.0.0でしか聞くことができません、それに接続することはできません。 127.0.0.1を試しましたか? (またはコンテナのIPアドレスが何であれ)。 – kennytm