tunnelblick “can’t assign requested address” error

When switching local networks (e.g., moving from home to the office), Tunnelblick refuses to connect to a VPN. Having the following error in Tunnelblick logs:

TCP: connect to [AF_INET]<VPN server IP address:port> failed: Can't assign requested address
...
Exiting due to fatal error

Checking routes in macOS (192.168.43.141 was the gateway last time we were able to connect with tunnelblick, 192.168.11.1 is the gateway for the network we are currently connected to):

> netstat -nr
Routing tables

Internet:
Destination        Gateway            Flags        Netif Expire
default            192.168.11.1       UGSc           en0
<VPN server IP>    192.168.43.141     UGSc           en0
...

The problem seems to be that a wrong gateway IP to the VPN server is being used (because of the local network switch), and Tunnelblick is not able to update the route.

Workaround is to flush the route (so a correct route to the vpn server is added). en0 is the interface being used to connect to the Internet:

> sudo ifconfig en0 down
> sudo route flush
> sudo ifconfig en0 up

After this, Tunnelblick connection is successful.

updatedupdated2020-10-142020-10-14