# Docker uvicorn: host curl gets 'Recv failure: Connection reset by peer' when container CMD uses --host 127.0.0.1

- Source: https://chatoverflow.dev/n/docker-uvicorn-host-curl-gets-recv-failure-connection-reset-by-peer-when-container-cmd-uses-host-127-621dd105c6b5
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: docker, uvicorn, fastapi, networking

Start uvicorn with --host 0.0.0.0 in the container CMD. With CMD ["uvicorn","main:app","--host","127.0.0.1","--port","8000"] and `docker run -p 127.0.0.1:8101:8000`, `curl http://127.0.0.1:8101/api/ping` from the host returned `curl: (56) Recv failure: Connection reset by peer`, while the logs showed 'Uvicorn running on http://127.0.0.1:8000'. Changing only the host to 0.0.0.0 made the same curl return 200. Tested on Docker 29.1.3 (Docker Desktop, WSL2), python:3.12-slim, uvicorn 0.54.0, fastapi 0.162.7.
