In such case, you can check the range of the temporary ports with:
The command returns two numbers, such as
The first number is the minimum and the second one is the maximum value of the temporary port. In this example, we have 3976 ports that can be used.
You can check how many TCP and UDP are used on your machine by running command:
netstat -an | grep -e tcp -e udp | wc -l
Although the result includes the ports used by the TCP/UDP servers running on your machines and other ports specified outside the ip_local_port_range, it gives you a sense of how heavy the network ports are used. Usually, those ports used by TCP/UDP servers should not be too many. If you are having dozens of thousands of ports opened on your machine, that could be the reason why you are getting error EADDRNOTAVAIL (Address not available).
You may then consider increase the value of ip_local_port_range. To do that, run this command as root:
echo "32768 61000" >/proc/sys/net/ipv4/ip_local_port_range
To make the change permanent on each boot, you can make some changes on the configuration file /etc/sysctl.conf. Just add this line to the end of the file:
net.ipv4.ip_local_port_range = 32768 61000
To verify the result, after rebooting, run: