OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions while running server

I was running the following code and above error has been occured.I tried turning off the firewall and windows security and the anti virus but it is not working how to change the access permission as per said or any other alternate solutions please

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST_NAME = socket.gethostname()
PORT = 12345
s.bind((HOST_NAME,PORT))
s.listen(4)
client, address = s.accept()
while True:
    message=input("Server:")
    client.send(bytes(message,'utf-8'))
    message_from_client=client.recv(100)
    print("Client:"+message_from_client.decode('utf-8'))

The error message followed was:

Traceback (most recent call last):
    s.bind((HOST_NAME,PORT))
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

I tried turning off the firewall and windows security and the anti virus but it is not working how to change the access permission as per said or any other alternate solutions please

  • Just bind to 0.0.0.0. No need for anything else.

    – 

Leave a Comment