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

I get forbidden access even when I run with administrative privileges. I re-run in again and it usually works. How can I fix this behavior?

(biobench-thMxqAli) λ guild tensorboard 1
Preparing runs for TensorBoard
WARNING: Guild took 27.80 seconds to prepare runs. To reduce startup time, try running with '--skip-images' or '--skip-hparams' options or reduce the number of runs with filters. Try 'guild tensorboard --help' for filter options.
WARNING: webfiles.zip static assets not found: c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\plugins\webfiles.zip
2021-02-17 15:04:42.417335: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2021-02-17 15:04:42.417554: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\sarat.chinni\.virtualenvs\biobench-thMxqAli\Scripts\guild.exe\__main__.py", line 7, in <module>
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\main_bootstrap.py", line 40, in main
    _main()
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\main_bootstrap.py", line 66, in _main
    guild.main.main()
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\main.py", line 33, in main
    main_cmd.main(standalone_mode=False)
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\click_util.py", line 213, in fn
    return fn0(*(args + (Args(**kw),)))
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\commands\tensorboard.py", line 108, in tensorboard
    tensorboard_impl.main(args)
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\commands\tensorboard_impl.py", line 46, in main
    _run_tensorboard(args)
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\commands\tensorboard_impl.py", line 98, in _run_tensorboard
    tensorboard.serve_forever(
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\tensorboard.py", line 636, in serve_forever
    run_simple_server(app, host, port, ready_cb)
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\tensorboard.py", line 602, in run_simple_server
    server, _ = make_simple_server(tb_app, host, port)
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\guild\tensorboard.py", line 615, in make_simple_server
    server = serving.make_server(host, port, app, threaded=True)
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\werkzeug\serving.py", line 847, in make_server
    return ThreadedWSGIServer(
  File "c:\users\sarat.chinni\.virtualenvs\biobench-thmxqali\lib\site-packages\werkzeug\serving.py", line 740, in __init__
    HTTPServer.__init__(self, server_address, handler)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 452, in __init__
    self.server_bind()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\http\server.py", line 138, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2032.0_x64__qbz5n2kfra8p0\lib\socketserver.py", line 466, in server_bind
    self.socket.bind(self.server_address)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

My guess is that the initial port selected is in use and Guild isn’t cycling correctly to a new port. That’s surprising though because the port is chosen at random and it would be terrifically low odds consistently pick a port that’s in use.

How often are you seeing this error?

I observe it quite often, once in 5-10 runs(kind of once in 1-2 days).

I usually run it again, once or twice and it starts working.

My guess is wrong, at least on Windows 10. This is quite surprising to me, but you can bind to a port in use without errors. I don’t think subsequent bindings are active but I would expect an error.

E.g. on Windows 10, using either admin or non-admin command prompts, you can run this command as many times as you like:

> python -m http.server 8080

The first time 8080 is bound appears to be the active socket listener. Subsequent commands won’t get connections. Very surprising behavior for an operating system.

But anyway, that’s unrelated I think.

What version of Windows are you running?

I am using Windows-10. Is the error due to already used ports from previous guild sessions?

I don’t think so. You can run this command multiple times without errors on Windows 10:

guild tensorboard --port 8080

I wonder if the range of legal ports on Windows 10 is narrower than Guild thinks. Let me take a look.

I’m not able to recreate a problem by picking the outer range of the ports that Guild uses.

On you system, can you replicate the error when you run either of these commands?

guild tensorboard --port 49152
guild tensorboard --port 65535