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.
More on Concurrency, async, tests, services & containers
`RuntimeError: asyncio.run() cannot be called from a running event loop` in a Jupyter notebook or inside an async framework.Intermediate`RuntimeWarning: coroutine 'fetch' was never awaited` and nothing happens.BeginnerAn asyncio health-checker is no faster than a sequential loop.Advanced`Task was destroyed but it is pending!` at shutdown.Advanced`OSError: [Errno 24] Too many open files` from an asyncio scanner with 20,000 targets.IntermediateA `ThreadPoolExecutor` job finishes "successfully" but half the work is missing, with no errors logged.Intermediate