OpenVPN write UDPv4: Can't assign requested address (code=49)

Problem

On Max OS X, when trying to connect to an OpenVPN gateway, you may encounter the following error:
2010-01-21 05:14:59 write UDPv4: Can't assign requested address (code=49)
2010-01-21 05:15:01 write UDPv4: Can't assign requested address (code=49)
...

The error would repeat itself indefinitely.

Root Cause

The TCP stack of the Mac has a bug that can cause the routing table to get corrupted.

Solution

The routing table needs to be flushed on the interface used to connect to the Internet. Typically,

  • en0: ethernet (wired) interface
  • en1: wlan (wireless) interface

The easiest way is to flush the routes is to reboot. The elegant way however is to shut down the interface connecting the Mac to the Internet, flush the routing table, and bring the interface back up. For example, assuming a wired connection, open a terminal or an X11 xterm window and issue the following commands:
sudo ifconfig en0 down
sudo route flush
sudo ifconfig en0 up

In case the command line hangs after the flush command, just open a new terminal and run the last command from there. When you are done, you can close all terminals. If you are connecting with wireless, replace en0 with en1.

References

OpenVPN error: write UDPv4: Can’t assign requested address (code=49)

This entry was posted in Mac OS X and tagged , , . Bookmark the permalink.
  • Anonymous

    Thanks! This resolved a problem I was having with a VPN app called Shimo using vpnc. Or at least it allowed me to avoid rebooting.

    • http://wdream.com/ Balazs

      Glad that it worked for you. Slightly off topic: I still can’t use Shimo when full routing is enabled. The Mail App simply crashes. The problem doesn’t happen when the VPN isn’t the default gateway (i.e. not all traffic is routed through the VPN.)

NewPush has solutions to fit your business needs.  For more than a decade, our focus has been to take on the technical challenges that are the hardest and most time-consumming.  Our goal is to free up your resources to focus on the core activities of your business and to drive your business performance.  Please visit our main site at newpush.com for more information or call us at +1-303-423-4500.