Docker Community Forums

Share and learn in the Docker community.

Localhost connection refused

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

- “1433:1433”

- “5000:80”

The app container ->80/tcp

Any help is appreciated.

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

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:
- auth-net

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?

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:

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

Although I’m not using WampServer, I do get problems with Chrome refusing to access ports of localhost from time to time. I found clearing the cookies and files from the cache to resolve most of my issues myprepaidcenter.