I have a problem, I can't figure out what the error is. Everything worked, the next day the server stopped connecting to the database. Created a new test project and the error is reproducible. But when I create a database with Docker and the server, everything is connected.
This gives an error, I don't understand what kind of rhombuses are
[Nest] 9964 - 2021-02-18 2:51:09 PM [TypeOrmModule] Unable to connect to the database. Retrying (1)... +65ms
error: ������������ "admin" �� ������ �������� ����������� (�� ������)
at Parser.parseErrorMessage (D:\Programs\Test_DB_Server\test-db\node_modules\pg-protocol\dist\parser.js:278:15)
at Parser.handlePacket (D:\Programs\Test_DB_Server\test-db\node_modules\pg-protocol\dist\parser.js:126:29)
at Parser.parse (D:\Programs\Test_DB_Server\test-db\node_modules\pg-protocol\dist\parser.js:39:38)
at Socket.stream.on (D:\Programs\Test_DB_Server\test-db\node_modules\pg-protocol\dist\index.js:10:42)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
so trying to connect
@Module({
imports: [
TypeOrmModule.forRoot({
type: 'postgres',
port: 5432,
host: 'localhost',
username: 'admin',
password: 'admin',
database: 'nestjs',
entities: [],
})
]
})
export class DatabaseModule {
}
docker compose
version: "3"
services:
postgres:
container_name: postgres_test
image: postgres:latest
ports:
- "5432:5432"
env_file:
- docker.env
pgadmin:
links:
- postgres:postgres
container_name: pgadmin
image: adminer
ports:
- "8080:8080"
env_file:
- docker.env
docker.env
POSTGRES_USER=admin
POSTGRES_PASSWORD=admin
POSTGRES_DB=nestjs
It is possible to connect to the database through the adminer, but it has not been connected through the TypeOrmModule since yesterday, and it correctly displays other errors (if the password is not correct, etc.). Help anyone with what you can.
You need to create network and bind them to same network to see each other. After that you can use "postgres" instead of localhost.
version: "3"
services:
postgres:
container_name: postgres_test
image: postgres:latest
networks:
- server-net
ports:
- "5432:5432"
env_file:
- docker.env
pgadmin:
links:
- postgres:postgres
container_name: pgadmin
image: adminer
networks:
- server-net
ports:
- "8080:8080"
env_file:
- docker.env
networks:
server-net:
driver: bridge
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.