Traefik host not accessible using Ping or HttpClient from dotnet applicatoin

Problem Description
I have a service running inside docker (docker running on my windows 10 machine)and is accessible through Traefik acting as a reverse proxy. "Host(pixel.docker.localhost)" is accessible over browser and postman. However, If I try to ping this from command line ping https://pixel.docker.localhost or try to access this pixel.docker.localhost over a get request using HttpClient in a .net console app running on my windows machine , I get error that "no such host exists".
I modified the host file on my windows machine and added an entry as below:
192.168.x.x pixel.docker.localhost
After adding this entry, I am able to ping https://pixel.docker.localhost as well as access this using HttpClient in a .net console app running on my windows machine.

Question
Why are browser and postman able to resolve pixel.docker.localhost without entry in host file but ping command from cmd and HttpClient fails to find this host ?

Seems that it is not Traefik related question but rather how to Windows DNS name resolutions work.
Do we have a Windows expert in our community that could explain that topic?

Thank you,

Its not windows either. Firefox, Chrome, Postman and I'm sure others resolve(in application) *.localhost to the loopback address.

Linux can be configured via a nsswitch plugin to resolve them natively also.

This works in browser.

$ curl -k https://site.localhost
curl: (6) Could not resolve host: site.localhost
1 Like

Thanks for clarifying. Do you know if Traefik can be configured for localhost scenario differently that would not require me to modify hosts file on windows? It should be fine for me to access Traefik over https://localhost:port instead of pixel.docker.localhost. However, I am not sure how would I configure that.
I will also try to find if dotnet httpclient has a mechanism to resolve *.localhost to the loop back address.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.