gpt4 book ai didi

node.js - 错误 : connect ECONNREFUSED 127. 0.0.1:5432 docker 迁移

转载 作者:行者123 更新时间:2023-11-29 12:51:12 25 4
gpt4 key购买 nike

我正在尝试迁移数据,但它始终找不到我的 postgreSQL。

version: '3'
services:
server:
build: ./server
ports:
- 3002:3002
depends_on:
- db
environment:
CORS_ALLOW_ORIGINS: http://localhost:8080,http://localhost:80
PORT: 3002
DEBUG: vuichoi*
DEBUG_HIDE_DATE: 1
SECRET_OR_PRIVATE_KEY: secret
SECRET_OR_PUBLIC_KEY: secret
DATABASE_URL: postgres://vuichoi:@db:5432/vuichoi #point the server container to the db container's IP address
command: bash -c "sequelize db:migrate && sequelize db:seed:all"
db:
ports:
- 5432:5432
environment:
POSTGRES_USER: vuichoi
POSTGRES_DB: vuichoi
image: postgres:10

配置.json

{
"development": {
"username": "vuichoi",
"database": "vuichoi",
"host": "localhost",
"dialect": "postgres"
},
"test": {
"username": "vuichoi",
"password": "vuichoi",
"database": "database_test",
"host": "localhost",
"dialect": "postgres"
},
"production": {
"use_env_variable": "DATABASE_URL"
}

}

在 docker-compose up --build 之后 enter image description here

当我尝试迁移时:

enter image description here

最佳答案

我通过将 config.json 中的“localhost”替换为“host.docker.internal”来修复,然后它可以顺利运行。问题可能是找不到我的 Db 容器

关于node.js - 错误 : connect ECONNREFUSED 127. 0.0.1:5432 docker 迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53572374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com