Interview Prep/Python for DevOps/Concurrency, async, tests, services & containers

Flask app in Docker is unreachable: `curl: (52) Empty reply from server` or connection refused on the published port.

BeginnerTroubleshootingConcurrency, async, tests, services & containers
Answer

Likely causes → The server binds to 127.0.0.1 inside the container (Flask's default), so it only accepts connections from inside the container.

Diagnose →

docker exec <c> ss -ltnp        # shows 127.0.0.1:5000
docker logs <c> | grep "Running on"

Fix → Bind to all interfaces: gunicorn -b 0.0.0.0:8000 app:app or flask run --host 0.0.0.0.

Prevent → Production server config in the image's CMD, not the dev server.

All Python for DevOps questions Roadmap: Python for automation

More on Concurrency, async, tests, services & containers