David
David

Reputation: 25

OSError: [WinError 10049] The requested address is not valid in its context

When I'm running the code:

name = socket.gethostname()

#ip = socket.gethostbyname(name)
port = 5000

ip = "90.95.52.220"
print("Ip server: %s"%ip)

s.bind((ip, port)

I get this error:

"OSError: [WinError 10049] The requested address is not valid in its context"

If I get the IP using socket.gethostbyname(name) it gives me an IP, but by using that IP other people can't connect to my server. What can I do? I read answers at similar questions but none of them worked.

Upvotes: 2

Views: 17380

Answers (1)

Raja Sudhan
Raja Sudhan

Reputation: 121

Your system might have many ip addresses assigned to it. In windows you can see by ipconfig /all command. But only one ip address is external. You need to bind to that ip address for your freinds to connect to you. If your system is connected through wifi, then it will be your wifi adapter ip address.

Upvotes: 4

Related Questions