Strange network problems on OS X

The strange problems I am having occurred 3 times now with a little over 1 month in between. Suddenly I am losing the ability to do some network related activities, but not all.

When it happens, these still work:

  • Resolve domain names using eg ping / dig
  • Skype
  • Fantastical (with google calendar sync)
  • SSH connections are not disconnected, but I can not create new ones
  • I can ping, and get responses back

However, these do not work:

  • All browsers (Chrome, Firefox, Safari), won't display pages.
  • Connected web-pages that uses web-sockets or SSE are losing connections (both over http and https).
  • Curl won't grab pages.
  • Adium disconnects and won't reconnect.
  • Sonos (inside my LAN) won't work anymore.
  • Evernote stops syncing.

The output of curl trying to grab a page is showing Can't assign requested address

{ ~ }$ curl google.com
curl: (7) Failed to connect to 84.208.42.35: Can't assign requested address 

My ifconfig looks just like it should.

netstat -an doesn’t contain an overwhelming number of entries:

1 CLOSE_WAIT
1 SYN_SENT
2 CLOSED
2 FIN_WAIT_2
13 FIN_WAIT_1
16 LISTEN
212 LAST_ACK
446 ESTABLISHED

I am on a MacBook Pro early 2011 model running OS X 10.9.1 connecting over wireless. This is the only device on the network with this problem. The only thing that helps is restarting the Mac. There are really not much to see in the logs either (as I've spotted at least), only services having sudden problems connecting.

Has anyone else been having problems like this? What is the best way to troubleshoot this the next time it happens?


As l'L'l stated, this problem does seem to be described here:
https://discussions.apple.com/thread/5551686?start=45&tstart=0

A temporary solution would be to open terminal and type:

sudo ifconfig en0 down
sudo route flush
sudo ifconfig en0 up

replace en0 with whatever port you are using to connect to the internet. This command essentially resets your connection without having to reboot your computer.


The ifconfig + route flush solution by @blaine prompted me to look in netstat -nr and sure enough I had a static host route to the gateway, with a high usage count (5th column in the netstat -nr output.)

When this happens again, you might want to check if you have a route for the address prefix that you are trying to connect to, and if it exhibits the same issue. For me, I didn't have to bring down the interface; just doing a route delete <dest> <gateway> (and adding it again if necessary) worked.