I am fairly new to docker and I do not know what's causing the issue to not run my python script on docker.. here is how i am creating my docker-compose.yml
version: "3.6"
services:
app :
build: ./app/
db:
build: ./database/
Here is the error :
File "/usr/local/lib/python3.9/site-packages/psycopg2/__init__.py", line 127, in connect
app_1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
app_1 | sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
app_1 | Is the server running on host "127.0.0.1" and accepting
app_1 | TCP/IP connections on port 5432?
upon running docker-compose ps:
Name Command State Ports
------------------------------------------------------------------------------------
542132_app_final_db_1 docker-entrypoint.sh postgres Up 5432/tcp
app_1 python abc ... Exit 1
How do I solve it? Please help. I am fairly new to Docker/Docker-compose. Thanks!
127.0.01. Trydbin database connection info which is the name in your compose file.