Help! I Can’t Connect to My PostgreSQL Container

0
9
Asked By TechNerd88 On

I'm having a tough time connecting to my PostgreSQL container after setting it up. I used the following command to create the container:

```bash
docker run -d --name postgres-avaliacao -e POSTGRES_USER=candidato -e POSTGRES_PASSWORD=av4li4cao -e POSTGRES_DB=avaliacao -p 5432:5432 postgres:latest
```

I've also written some scripts for testing the connection and running the initial migration with NestJS and TypeORM. However, I keep getting the error: "Connection failed: error: password authentication failed for user 'candidato'."

I've tried changing the credentials, resetting Docker Desktop, deleting all containers/images, and even rebooting my Windows 11 machine. I also tested the connection using a Python script, but it didn't work either. Any help would be greatly appreciated!

2 Answers

Answered By DockerDude54 On

When you're connecting from one container to another, using `localhost` won't work. Instead, use the name of the container. You might also want to look into Docker Compose; it would help simplify things for your setup.

TechNerd88 -

Thanks for the heads up! I appreciate it; I'll definitely check out Docker Compose.

Answered By ConcernedUser007 On

I get that tech issues can be frustrating, but make sure you're not overlooking the basics. Double-check your credentials and ensure that you've mapped the ports correctly when running the container.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.