Cannot Access the WiFi Internet on Mac with: Cannot Allocate Memory

I have been noticing more and more frequently then when I switch between WiFi connections or switch between wired and WiFi connections that sometimes my WiFi connection would show that it was online, but I was unable to access anything on the LAN or WAN. I have experienced similar issues when DNS is not working properly, so my first test is to validate DNS is working. With this recent issue my test always returned:

So what is going on and how can you fix the issue?

mac-wifi

Well a few bullet points to start:

  • Based on the error message, it would appear that DNS is not the issue. Of course, this can be confirmed by changing the configured DNS servers and testing again — the results will be the same.
  • Disconnecting and reconnecting the WiFi does not make a difference. However going from WiFi back to a wired connection does get you back on the Internet. Switching back from wired to WiFi will bring back the same issue.
  • If you pull a Windows and restart the issue goes away temporarily.

In short, the issue is known and there are some workaround, by how do you fix the issue when it occurs? Well, a quick Google search on the error messages brings up a ton of forums with people experiencing the same issue. Many suggest changing the proxy settings on the Mac to automatic, but in my case that had no effect.

After spending quite a bit of time looking for another answer, I came across someone who suggested deleting the route to the gateway of the WiFi you are connecting to. In short, when you connect to WiFi, you connect to a router. That router is responsible for routing your traffic. It does this by acting as a gateway. It either knows where to send your traffic because it controls IP or it sends the traffic upstream.

I found this suggesting interesting because I had noted that sometimes switching the WiFi from one access point to another sometimes fixed the issue without a restart. I decided to give this a try. First up, I had to find out what my default gateway was:

Based on this, I know my default gateway is 192.168.1.1. Next, to delete the route:

Finally, disable and then enable WiFi. After completing these steps, I was back online! This meant I had a fix, but it was not permanent or automatic. To make it permanent and automatic, I needed to write-up a little script:

You could then run the above script on a cronjob at an interval of your choosing. Now, based on my testing, this issue only happens when joining an access point so you could check for WiFi changes prior to checking for and fixing this known issue:

You could choose to run this alternative script on a while true loop with a sleep time of your choosing. I hope this helps someone is it was quite a pain for me!

© 2015, Steve Flanders. All rights reserved.

2 thoughts on “Cannot Access the WiFi Internet on Mac with: Cannot Allocate Memory

Leave a Reply