OpenVPN: Socket Bind Failed on Local Address

PowerADM.com / OpenVPN / OpenVPN: Socket Bind Failed on Local Address

I cannot connect to an OpenVPN server from a Windows client with the following error in the openvpn.log:

TCP/UDP: Socket bind failed on local address [AF_INET]127.0.0.1:22194: Cannot assign requested address
Exiting due to fatal error

OpenVPN TCP/UDP: Socket bind failed on local address

To solve this problem, I have to reboot the computer or restart the Service Host: Network Service, which is very inconvenient.

I’ve only encountered this problem when TCP is used to connect to the OpenVPN server. I have never had this problem when using UDP.

If the problem occurs when you try to connect to multiple OpenVPN servers at the same time, check that multiple TAP/WinTun virtual network adapters are available in Windows.

In this case, an error will appear in openvpn.log and/or OpenVPN GUI:

All TAP-Windows/WinTun adapters on this system are currently in use

If you have more than one network adapter in Windows, check to see which process/program is using the outbound port that is specified in the details of the error. You can use netstat or PowerShell to find and kill a process that is listening on a specific port:

  • TCP port:
    Get-Process -Id (Get-NetTCPConnection -LocalPort 22194).OwningProcess
  • UDP port:
    Get-Process -Id (Get-NetUDPEndpoint -LocalPort 22194).OwningProcess

If no one is listening on the specified port, the computer might have Hyper-V services installed or WSL2 running.

This is because Windows reserves a certain dynamic range of TCP ports for Hyper-V/WSL. You can display this port range with the command:

netsh int ipv4 show excludedportrange tcp

Protocol tcp Port Exclusion Ranges
Start Port End Port
---------- --------
5985 5985
47001 47001

Protocol tcp Port Exclusion Ranges on Windows

You will get an error if this range overlaps with the outgoing port range of the OpenVPN client: TCP/UDP: Socket bind failed on local address. Change the outgoing port range in the OpenVPN client settings:

  1. Right-click on the OpenVPN GUI tray icon;
  2. Select Settings -> Advanced -> Management interface, and change the Port Offset value so that it is not in the reserved range; OpenVPN GUI change port offset
  3. Save the changes.

After that, you will be able to connect to your OpenVPN server.

You can also set a fixed outgoing port for the OpenVPN client in the .ovpn file using the following directive:

lport 10001

Leave a Reply

Your email address will not be published. Required fields are marked *