fastapi curl works inside a container. curl on host machine: Connection reset by peer

  Kiến thức lập trình

I have a fastapi instance running inside a container.

when I exec bash into it, I can run what’s below and it works:

root@974b874a42eb:/code# curl http://localhost:9090

when I run the same thing from the host machine I get:

j@fedora:~/Projects$ curl http://localhost:9090
curl: (56) Recv failure: Connection reset by peer

the run command is:

podman run -d -p 9090:9090 -v ./app:/code/app:rw -v ./tests:/code/tests:rw --cap-add=ALL --rm --name ${LOCAL_NAME} ${LOCAL_NAME}

the start command is:

CMD ["fastapi", "dev", "/code/app/", "--port", "9090", "--host", "", "--reload"]

I would imagine the main culprit would have been only listening to localhost but you can see what I set –host to.

also its an unprivileged port

also I believe this worked before as expected a month ago on a different version of podman.

how can I fix it so that I can expose fastapi correctly to the host machine or any other client?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website