[resolved] Docker localhost issue

Resolved: proxy was broken on ipv6, updated my reverse proxy to connect directly to 127.0.0.1
———
I’m currently experiencing an issue with docker while running a container on a server.
Running on Debian 11, docker 20.10.5+dfsg1.
I was running Vaultwarden (a Bitwarden server) previously, but a day or two ago it stopped responding to requests from localhost on the assigned port.
The container was initially started with:

docker run -d \
  --name vaultwarden \
  --restart unless-stopped \
  -v /var/lib/vaultwarden/:/data/ \
  -p 8880:80 \
  vaultwarden/server:latest

Right now, when I curl localhost:8880 I get the error “curl: (56) Recv failure: Connection reset by peer
However, when I curl 172.17.0.2:80 (the IP address of the container) I get the data of the login page as expected.
This is the only container experiencing this issue, all other containers respond to localhost as expected.
What could be causing this issue, and how could I try to resolve it?
I have tried restarting docker, re-running the container, and changing the host port.

What I’ve been doing lately is ensuring all references to localhost is replaced with 127.0.0.1

My problem was similar, in my case for some weird reason the docker container gets the ip 192.168.0.5 wich is in the same sub-network from my wifi router, my solution was force another ip to my docker container in to docker-compose.yml:

services:
    node:
      container_name: ${PROJECT_NAME}-${PROJECT_ENV}-${PROJECT_COMPONENT}
      stdin_open: true
      build:
        context: ./
        args:
          project_env: ${PROJECT_ENV}
      ports:
        - ${FRONTEND_EXTERNAL_PORT}:8080
      volumes:
        - /app/node_modules
        - .:/app
      networks:
        vpcbr:
          ipv4_address: 10.5.0.5


networks:
  vpcbr:
    driver: bridge
    ipam:
     config:
       - subnet: 10.5.0.0/16
         gateway: 10.5.0.1

It can happen when you run many compose projects without deleting the networks so there is no more IP range t assign to the container. Or in older Docker installations (I don’t know if it can still happen) even if I deleted docker networks, Docker didn’t start to reuse subnets until I restarted the Docker daemon.