Skip to content Skip to sidebar Skip to footer

Oserror [errno 99] - Python

i want to execute the following simple server code: import socket s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port =

Solution 1:

If it works using the ip address but not using hostname.

You should have something like this in your /etc/hosts mapping ip to hostname.

127.0.0.1   localhost
127.0.1.1   your_hostname_here

# The following lines are desirable for IPv6 capable hosts::1     ip6-localhost ip6-loopbackfe00::0 ip6-localnetff00::0 ip6-mcastprefixff02::1 ip6-allnodesff02::2 ip6-allrouters

Your /etc/hostname should obviously be the same as above.

Reboot and you should be able to ping your hostname successfully.

You can also use socket.gethostbyname(socket.gethostname()) to get the i.p as opposed to the hostname

Solution 2:

Try set the SO_REUSEADDR option to the socket:

s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

Post a Comment for "Oserror [errno 99] - Python"