Chapter 4 database would not connect
enoonan opened this issue · 0 comments
enoonan commented
I am going through the book, just on chapter 4. When I tried to initialize a shopping basket through the Swagger UI, I got the following error:
{
"code": 13,
"message": "failed to connect to `host=/tmp user=mallbots_user database=mallbots`: dial error (dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory)",
"details": [
{
"@type": "type.googleapis.com/errors.ErrorType",
"TypeCode": "INTERNAL_SERVER_ERROR",
"HTTPCode": "500",
"GRPCCode": "13"
}
]
}
I was able to fix it by directly setting environment variables in the docker-compose file rather than loading via env_file:
services:
monolith:
...
environment:
- PG_CONN=host=postgres dbname=mallbots user=mallbots_user password=mallbots_pass
- ENVIRONMENT=development
# env_file:
# - docker/.env
For some reason the .env file wasn't being read.
On MacOS Monterey 12.5
Thank you for the book BTW. Learning a ton and protobufs are blowing my mind 🤯