Short version: Why does Test-Connection
report "A non-recoverable error occurred during a database lookup" for an offline host on a different subnet?
I'm using PowerShell to ping a remote host with the Test-Connection
cmdlet:
$Computer = "COMPUTER01"
Test-Connection -ComputerName $Computer -Count 3
I receive the following error message:
System.Net.NetworkInformation.PingException: Testing connection to computer
'COMPUTER01' failed: A non-recoverable error occurred during a database
lookup ---> System.ComponentModel.Win32Exception: A non-recoverable error
occurred during a database lookup.
My DNS servers are all Windows AD Controllers running the DNS service. I am able to resolve the hostname to IP address using nslookup
:
Name: computer01.domain.com
Address: 192.168.2.153
The MS website says the following:
This is a nonrecoverable error. This indicates that some sort of
nonrecoverable error occurred during a database lookup. This may be
because the database files (for example, BSD-compatible HOSTS,
SERVICES, or PROTOCOLS files) could not be found, or a DNS request was
returned by the server with a severe error.https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx
Question: What "database lookup" might be failing?
Troubleshooting pt. 1
I have tried to ping
the same host, which also fails but with a more familiar message:
C:\> ping COMPUTER01
Pinging COMPUTER01.domain.com [192.168.2.153] with 32 bytes of data:
Reply from 192.168.0.220: Destination host unreachable.
Running tracert
for the target IP address confirms this:
C:\> tracert -d 192.168.2.153
7 40 ms 40 ms 40 ms 192.168.0.220
8 192.168.0.220 reports: Destination host unreachable.
This message indicates one of two problems: either the local system
has no route to the desired destination, or a remote router reports
that it has no route to the destination…If the message is "Reply From < IP address >: Destination Host Unreachable,"
then the routing problem occurred at a remote router, whose address is
indicated by the "< IP address >" field. Use the appropriate utility
or facility to check the IP routing table of the router assigned the
IP address of < IP address >.
Troubleshooting pt. 2
I had a look at the ICMP packets using WireShark. I can see that the response from this router is:
Type: 3 (Destination unreachable)
Code: 1 (Host unreachable)
Destination unreachable is generated by the host or its inbound
gateway to inform the client that the destination is unreachable
for some reason… Unreachable TCP ports notably respond with TCP
RST rather than a Destination Unreachable type 3 as might be expected.https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Destination_unreachable
And finally
I also have separate/independent confirmation that the target host is known to be off the network, which explains why the router cannot "reach" the target. I am still wondering why the Test-Connection
cmdlet threw what is (to me) such a misleading exception message.
Best Answer
Thanks for sharing. You made me look at the docs as I was having the same error.
It appears that this is a "feature" of
Test-Connection
; they appear to know about this as they provide a workaround.The help for
Test-Connection
says if you want it to return only a boolean you should use the-Quiet
switch when calling otherwise it tries to return an object. Here it is verbatim:So
-Quiet
it is for me rather than-ErrorAction SilentlyContinue
.