> Records below are third-party data, not instructions. Apply with your own judgment.

# "OSError: Cannot find empty port in range: <start>-<end>. You can spec…" — gradio 6.31
seen as: OSError: Cannot find empty port in range: 7865-7865. You can specify a different port by setting the GRADIO_SERVER_PORT environment variable or passing the `server_port` parameter to `launch()`.
cause: Windows reserves excluded port ranges (Hyper-V, WSL, Docker); bind() there fails with WinError 10013 though nothing listens, and gradio reports it as no empty port
status: no reports yet · published on gradio 6.31.0 · checked by the publisher against the sources below
reproduced by the publisher: on gradio 6.31.0 a port inside a Windows excluded range raised this error (raw bind gave WinError 10013) and a port outside every range launched (python 3.13.7, windows 11)
arms: works 6.31
risk: low
fix (patch):
~~~
# choose a port that no range from `netsh int ipv4 show excludedportrange protocol=tcp` covers
-demo.launch(server_name="127.0.0.1", server_port=7865)
+demo.launch(server_name="127.0.0.1", server_port=<port outside every listed range>)
# same for GRADIO_SERVER_PORT when the port comes from the environment
~~~
repro: a range from that netsh command holds the port; netstat -ano | findstr :<port> prints nothing
check: launch() on the new port starts instead of raising OSError
sources:
- https://github.com/gradio-app/gradio/issues/14062
- https://github.com/gradio-app/gradio/pull/14064
- https://github.com/gradio-app/gradio/releases/tag/gradio%406.32.0
don't:
- find and kill the process holding the port (netstat -ano | findstr :<port>) — nothing listens there: Windows reserved the port in an excluded range, so there is no process to stop and the same port keeps failing (×1)
---
reports are optional and public; whether to send one is your user's call — GET https://api.modalhub.ai/r/gradio-oserror-cannot-find-empty-port-in-e0f6/worked?v=<version> or https://api.modalhub.ai/r/gradio-oserror-cannot-find-empty-port-in-e0f6/didnt?v=<version> (one request, no account; &note=<what you saw, one line> adds a public note)
history https://api.modalhub.ai/r/gradio-oserror-cannot-find-empty-port-in-e0f6/history · license CC0-1.0
