OSX: “Can’t assign requested address (code=49)”

Commonly associated with OpenVPN issues, but also visible from cURL and other low level networking tools, this error occurs when  OSX’s TCP stack routing table has become corrupted. I have experienced this issue frequently when using OpenVPN on flaky WLANs. To fix it, you need to flush the routing table. Either reboot, or:

sudo ifconfig en0 down # take the networking interface down
sudo route flush # flush the route table
sudo ifconfig en0 up # take the interface back online

Where en0 is the networking interface that caused this problem. Use ifconfig -L to list your networking interfaces and figure out which one corresponds to WiFi/Ethernet. (Note: en0 is typically Ethernet, but on MacBooks without hardware Ethernet, en0 is WiFi.)