Search code examples
pythonwindowssockets

Python sockets and windows


I got this small script:

import socket

with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as server_socket:
    server_socket.bind(("127.0.0.1", 5353))

Running it under windows, I got the error PermissionError: [WinError 10013] Der Zugriff auf einen Socket war aufgrund der Zugriffsrechte des Sockets unzulässig

I cannot run it as admin, because I am using an IDE.

Any ideas? TIA!


Solution

  • port 5353 is a mdns service and most likely used by your OS. choose a different one, then it works. you can also check open ports with netstat (e.g. netstat -a -b -p UDP)