Nodejs:
import * as Sequelize from 'sequelize'
const fn =async ()=>{
const sequelize = new Sequelize.Sequelize('postgres://a:a@localhost:5432/a')
console.log('1');
try {
// setInterval(()=> console.log(`>>`), 1000)
const a = await sequelize.authenticate();
console.log('Connection has been established successfully.', a);
} catch (error) {
console.error('Unable to connect to the database:', error);
}
console.log(`>>>ss`)
}
fn()
Only logs out:
1
Done in 2.41s.
Which is odd. It closes my node server, no error, just shuts down.
So I tried port 5432 on:
- localhost
- 192.168.0.1
- 192.168.65.0
- 0.0.0.0 (docker ps shows
0.0.0.0:5432->5432/tcp
)
But no chance to work. How are you able to connect to the db? I always had issues with docker on windows, seems to be setup on a different network than what my browser and node.js process can access.
If I use adminer, it can access the db. (I can login and see db)
введите описание изображения здесь
dockercompose:
version: "3.7"
services:
db:
restart: always
image: postgres:12.3-alpine
environment:
POSTGRES_DB: a
POSTGRES_USER: a
POSTGRES_PASSWORD: a
ports:
- "5432:5432"
adminer:
image: adminer
restart: always
ports:
- 8080:8080
Pg admin работает *
Docker проверить:
"PortBindings": {
"5432/tcp": [
{
"HostIp": "",
"HostPort": "5432"
}
]
},
Ребята, вы знаете, что делать?