Docker Community Forums

Share and learn in the Docker community.

Localhost connection refused


(Cb3431) #1

At a loss here. I have an ASP.NET Core app with SQL Server. My docker compose file spins up both.
Windows 10 Pro
Docker - 17.12.0-ce

I can reach SQL from the host using localhost,1433. I can no longer reach the site using localhost:5000. localhost:5000 was working, but now I get connection refused in Chrome.

docker file for the app has EXPOSE 80

SQL:
ports:
- “1433:1433”

App:
ports:
- “5000:80”

The app container - 0.0.0.0:5000->80/tcp

Any help is appreciated.


(Sam) #2

and, is the app running in the app container? expose doesn’t DO anything on the container itself…
the app must be running and listening on the port


(Cb3431) #3

The app is running. I can access it if I get the IP address and use that.
Says now listening on http://[::]:80 when I start the container. That tells me it’s listening on port 80 in the container and then I’m mapping that port to 5000 on the host.

I also have:
networks:
- auth-net

networks:
auth-net:
external:
name: nat

I’m running Windows 10 Pro Build 17123.rs4. It’s my understanding that localhost should now be working in the latest builds of Windows 10 and localhost isn’t working. I’m able to access the site using the ip:5000. Can anyone offer any help understanding what’s wrong?


(Raj Chaudhuri) #4

This is a known current limitation of Docker for Windows. You cannot use localhost or any of the host’s IP addresses or names to access containers from the host itself. External machines can do so. On the host, you can only use the container’s IP address and port to access the container.

Details can be found on the following github issue:


(Cb3431) #5

While that was the case in 2016, the limitation has been removed.

https://blogs.technet.microsoft.com/networking/2017/11/06/available-to-windows-10-insiders-today-access-to-published-container-ports-via-localhost127-0-0-1/