Error: Failed to retrieve TUN Socket

Posted on August 3, 2013 @ 11:58 pm

Problem/Error Message: Newer versions of DroidVPN starting from 2.1p will show the "Failed to retrieve TUN Socket" or "Failed to initialize TUN Socket" error message.

If you check your logcat you will see an error message like this

E/VpnJni ( 1165): Cannot allocate TUN: Bad file number
E/DroidVPNService(24348): java.lang.IllegalStateException: Cannot create interface
E/DroidVPNService(24348): at android.os.Parcel.readException(Parcel.java:1335)
E/DroidVPNService(24348): at android.os.Parcel.readException(Parcel.java:1281)
E/DroidVPNService(24348): at android.net.IConnectivityManager$Stub$Proxy.establishVpn(IConnectivityManager.java:1321)
E/DroidVPNService(24348): at android.net.VpnService$Builder.establish(VpnService.java:472)

Cause: The VPN API on Android was added from ICS (4.0) and above. Some vendors/Operators/Rooted flavors of the OS have ported ICS to the devices with missing libraries and functionality. This might result in failure to create VPN tunnel. The important library that is missing from those devices is tun.ko

This could also happen if the ownership of /dev/tun is not set correctly

you can recognize the problem by looking at your logcat and seeing the following error line:

"VpnJni : Cannot allocate TUN: Bad file number"

If this line appears then there is a missing library on the device or the permission on /dev/tun is not set correctly which prevents DroidVPN from establishing the VPN tunnel.

We have also received reports that it could be caused by some ROMs that are not automatically loading the TUN module.

Solution: Try to upgrade your device to the latest OS release.

Try contacting your device vendor about VPN support on your OS.

If your device is rooted try executing these commands

# insmod tun.ko
# mknod /dev/tun -c 10 200
# chmod 0666 /dev/tun
# chown system /dev/tun

×