Can not resolve localhost on computer that is using pihole as dns

Please follow the below template, it will help us to help you!

If you are Experiencing issues with a Pi-hole install that has non-standard elements (e.g you are using nginx instead of lighttpd, or there is some other aspect of your install that is customised) - please use the Community Help category.

Expected Behaviour:

_[
I use Win 10 with WSL 2. I am trying to use nodejs/express to host a webserver on localhost.
When using WSL i get:

oswald@DESKTOP-MKNM8C4:~$ dig localhost

; <<>> DiG 9.11.3-1ubuntu1.12-Ubuntu <<>> localhost
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8855
;; flags: qr rd ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;localhost.                     IN      A

;; ANSWER SECTION:
localhost.              0       IN      A       127.0.0.1

;; Query time: 0 msec
;; SERVER: 172.27.16.1#53(172.27.16.1)
;; WHEN: Sat Jul 18 12:52:59 CEST 2020
;; MSG SIZE  rcvd: 52

oswald@DESKTOP-MKNM8C4:~$

]_

Actual Behaviour:

_[

But on windows host os i get:

C:\Users\oneti>nslookup localhost
Server:  raspberrypi
Address:  fd51:42f8:caae:d92e::ff

*** raspberrypi can't find localhost: Non-existent domain

C:\Users\oneti>

And because my browser runs in host os this is bad.

My conclusion is. that this is because of pi-hole because of the response of nslookup and because it happend right after.

]_

Debug Token:

[https://tricorder.pi-hole.net/3wz0ii3kbg]

That is normal behaviour, and it is not related to Pi-hole at all.

nslookup just considers DNS information.
Specifically, it does not query other local information that would be available to the OS on the machine you are executing nslookup from (e.g. /etc/hosts or mDNS), while other applications would.

Depending on its implementation, a DNS server may or may not respect local naming sources (e.g. Pi-hole's embedded dnsmasq does consider /etc/hosts), but naturally only those defined on the machine the DNS server runs on.

You will find that

ping localhost

works as expected on your Windows host, sending packets to either ::1 or 127.0.0.1.

I would get alerted if a DNS lookup via nslookup on localhost would actually return an IP address (there are some smart TVs that wrongly register localhost as a name for themselves).

Hello,

Thanks for the answer. You were right it was my misunderstanding about how these systems work i think.

I find it kind of confusing though, because after updating to pihole 5? Or i don't know what caused the change, but i can reach my locally hosted website from nodejs again and the answer of nslookup changed to:

C:\Users\oneti>nslookup localhost
DNS request timed out.
    timeout was 2 seconds.
Server:  UnKnown
Address:  fd51:42f8:caae:d92e::ff

DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
*** Request to UnKnown timed-out

I don't understand if this means if anything changed, but you are right, pinging localhost now works properly.