Terminal/Safari Cannot Resolve Host But Chrome Can Connect I have MacBook Pro (Retina, 13-inch, Early 2015) with OS X 10.11.5. 

Internet connection works only for Chrome. Safari and several terminal apps cannot connect to internet due to resolve host failure.

I read the following posts in stackexchange that describe similar connectivity issues: My native mac apps are not connecting to the internet, but Google Chrome does and works correctly. Why is this?

On the terminal:


ping google.com: ping: cannot resolve google.com: Unknown host
ping 8.8.8.8: 5 packets transmitted, 5 packets received, 0.0% packet loss
curl google.com: curl: (6) Couldn't resolve host 'google.com'
curl 8.8.8.8: curl: (7) Failed to connect to 8.8.8.8 port 80: Operation timed
ssh {servername} : ssh: Could not resolve hostname {servername}: nodename nor servname provided, or not known
nslookup google.com: This works correctly.
dig google.com: This works correctly.


I tried the followings a lot of times to no avail:


Renewing/turning off&amp;on/inputting manually DHCP.
Restarting/resetting the router and the macbook.
Turning WiFi on/off. This fixes the problem for a few minutes but then the connection drops again.
Set all network configurations except wifi to "make service unavailable" in network preferences.
Checked and copied all network settings from another macbook pro that's connected and online on my network.
Ran network diagnostic and assistant tools
Set Network > Wifi > Advanced > DNS > DNS servers to OpenDNS ip addresses: 208.67.222.222
No Proxies is checked or set under Network > Wifi > Advanced > Proxies.
Set TCP/IP > Configure IPv6 to "Link-local only" as suggested here:  Constantly dropping internet on El Capitan?
Logging in and connecting to internet with guest user account.


I tried running the following commands to reset DNS but they didn't run neither

$ sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
/System/Library/LaunchDaemons/com.apple.mDNSResponder.plist: Could not find specified service

$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist


I didn't try the followings:


Resetting SMC 
Removed the /Library/Preferences/SystemConfiguration folder.
Removed network password from keychain.


Other information that might be relevant: 


OS X Firewall is off.
I tried the following commands on terminal:

$ ifconfig en1
en1: flags=963&lt;UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX&gt; mtu 1500
     options=60&lt;TSO4,TSO6&gt;
     ether 4a:00:03:bd:de:d0
     media: autoselect &lt;full-duplex&gt;
     status: inactive
$ ifconfig awdl0
awdl0: flags=8943&lt;UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST&gt; mtu 1484
     ether 76:aa:18:a6:c9:49
     inet6 fe80::74aa:18ff:fea6:c949%awdl0 prefixlen 64 scopeid 0x8
     nd6 options=1&lt;PERFORMNUD&gt;
     media: autoselect
     status: active
$ sudo ifconfig awdl0 down



I did the last command because it was suggested here: Constantly dropping internet on El Capitan?


My modem router has no black/whitelist for any MAC addresses.
skype app doesn't connect. It is stuck in "connecting" state.


flushing DNS cache didn't help neither:

$ sudo dscacheutil -flushcache
$ sudo killall -HUP mDNSResponder
No matching processes were found


Here are the DNS server settings:

$ cat /etc/resolv.conf
#
# Mac OS X Notice
#
# This file is not used by the host name and address resolution
# or the DNS query routing mechanisms used by most processes on
# this Mac OS X system.
#
# This file is automatically generated.
#
nameserver 192.168.43.1



I run sysdiagnose command to produce the following report:

sysdiagnose_2016.12.19 (Dropbox d/l)
I can run mDNSResponder command on terminal. It returns no message back.
Your launch daemon com.apple.mDNSResponder.reloaded is not loaded properly.

You can check this by entering sudo launchctl list | grep DNS.

The result should yield something like this:

-   0   com.apple.mDNSResponderHelper.reloaded
108 0   com.apple.mDNSResponder.reloaded


108 is the pid and should differ on your system.



Check your com.apple.mDNSResponder.plist for errors with:

cat /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist


It should look like this:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.apple.mDNSResponder.reloaded&lt;/string&gt;
    &lt;key&gt;OnDemand&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;InitGroups&lt;/key&gt;
    &lt;false/&gt;
    &lt;key&gt;UserName&lt;/key&gt;
    &lt;string&gt;_mdnsresponder&lt;/string&gt;
    &lt;key&gt;GroupName&lt;/key&gt;
    &lt;string&gt;_mdnsresponder&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/usr/sbin/mDNSResponder&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;MachServices&lt;/key&gt;
    &lt;dict&gt;
        &lt;key&gt;com.apple.mDNSResponder&lt;/key&gt;
        &lt;true/&gt;
            &lt;key&gt;com.apple.mDNSResponder.dnsproxy&lt;/key&gt;
            &lt;true/&gt;
    &lt;/dict&gt;
    &lt;key&gt;Sockets&lt;/key&gt;
    &lt;dict&gt;
        &lt;key&gt;Listeners&lt;/key&gt;
        &lt;dict&gt;
            &lt;key&gt;SockFamily&lt;/key&gt;
            &lt;string&gt;Unix&lt;/string&gt;
            &lt;key&gt;SockPathName&lt;/key&gt;
            &lt;string&gt;/var/run/mDNSResponder&lt;/string&gt;
            &lt;key&gt;SockPathMode&lt;/key&gt;
            &lt;integer&gt;438&lt;/integer&gt;
        &lt;/dict&gt;
    &lt;/dict&gt;
    &lt;key&gt;POSIXSpawnType&lt;/key&gt;
    &lt;string&gt;Interactive&lt;/string&gt;
    &lt;key&gt;EnablePressuredExit&lt;/key&gt;
    &lt;false/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Remove the lines &lt;key&gt;com.apple.mDNSResponder.reloaded&lt;/key&gt; and the immediately following &lt;false/&gt; or &lt;true/&gt; from the file disabled.plist by editing it with

sudo nano /private/var/db/com.apple.xpc.launchd/disabled.plist


You may have to disable SIP to do so!

Remove the mDNSResponder daemon from the launchctl database with:

sudo launchctl remove com.apple.mDNSResponder.reloaded


Re-add it with 

sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist


Reboot.