If you are using docker compose with a network, change the url from localhost to the container name, e.g if your container is called backend on port 8080, it should be http://backend:8080 instead of http://localhost:8080 because of the network you establish in the compose.