Why can’t I connect to localhost in Windows 11?

I have Windows 11.

If I run a local server, I cannot connect to it from the browser.

For instance, if I run:

uv run python -m http.server
Serving HTTP on :: port 8000 (http://[::]:8000/) ...

And then I connect to http://localhost:8000 with either Firefox or Chrome, the page loads indefinitely.

If I run:

docker run -d -p 8080:80 docker/welcome-to-docker

…and then I try to connect to port 80, it says Firefox cannot connect to localhost:80, and yes the server is running:

> docker ps
CONTAINER ID   IMAGE                      COMMAND                  CREATED          STATUS          PORTS
                      NAMES
224204b6888a   docker/welcome-to-docker   "/docker-entrypoint.…"   53 seconds ago   Up 52 seconds   0.0.0.0:8080->80/tcp, [::]:8080->80/tcp   heuristic_ellis

Windows Firewall is disabled

enter image description here

I have BitDefender but the free version doesn’t even has a firewall.

Ping seems to work:

ping 127.0.0.1

Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms