Unable to connect to the database error on all containers

After updating my stack to the latest, I'm starting to get this same error in all containers that are not the databases:
[Nest] 1  - 01/30/2023, 8:29:01 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (2)...
Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
[Nest] 1  - 01/30/2023, 8:29:04 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (3)...
Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
[Nest] 1  - 01/30/2023, 8:29:07 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (4)...
Error: connect ECONNREFUSED 127.0.0.1:5432
`
However, all the containers are on the same network, and the container databases are just fine, ready to accept connections. Did something in the way the containers reach the database have changed? I don't understand why they are trying to go through localhost rather than using the container name.
Was this page helpful?