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

(stream) C:\Users\Ajinkya>streamlit hello
Traceback (most recent call last):
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Ajinkya\Miniconda3\envs\stream\Scripts\streamlit.exe\__main__.py", line 7, in <module>
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\streamlit\cli.py", line 193, in main_hello
    _main_run(filename)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\streamlit\cli.py", line 251, in _main_run
    bootstrap.run(file, command_line, args)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\streamlit\bootstrap.py", line 181, in run
    server.start(_on_server_start)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\streamlit\server\Server.py", line 213, in start
    start_listening(app)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\streamlit\server\Server.py", line 122, in start_listening
    app.listen(port)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\tornado\web.py", line 2042, in listen
    server.listen(port, address)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\tornado\tcpserver.py", line 143, in listen
    sockets = bind_sockets(port, address=address)
  File "c:\users\ajinkya\miniconda3\envs\stream\lib\site-packages\tornado\netutil.py", line 168, in bind_sockets
    sock.bind(sockaddr)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

Hi @aidlml — and welcome to the forum! :wave:

I found similar issues that might help:

It looks like Windows (or some other software) is blocking socket access to the provided port.
Please let me know if the issue persists!

I tried all possible things but unable to use streamlit on windows machine. :slightly_frowning_face:

Hi @aidlml,

Can you say, specifically, what you’ve tried so far?

Faced the same issue and I was able to solve it by changing the default port:

streamlit run app_name.py --server.port 5998

on windows machine with

streamlit==0.65.1

5 Likes

Try in the following order

netstat -a -o -n “”" Find #### “”"
taskkill /F /PID ####
pip install streamlit==0.65.1
streamlit run Filename.py --server.port ####

This works

Did your issue got resolved?

Hi! It seem we’ve encountered same problem “PermissionError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions” when running streamlit code via anaconda environtment terminal. It took me to resolve the issue more than 3 days :-(, still not bad. But here’s you need to do to resolve the issue:
The default server port of the streamlit is 8501, but there are cases that the 8501 server port is already in used in your system. You may try to verify it using this CMD Code: netstat -a
then wait until the process is completed. Once conpleted, enter this code again: netstat -na | find “8501”
If there the queries will find the 8501 port, then it means it is already in used.
Solution: Chose different port like 8502, 8503, … an so on. To do this, simply add the --server.port 8502 in your code.
Example: From
streamlit run “C:\USER\RAI\app.py”
Use the code: streamlit run --server.port 8502 “C:\USER\RAI\app.py”

Hope this will work.

  1. Open a command prompt in admin mode
  2. Type gpedit and press enter
  3. Navigate to Computer Settings\Windows settings\Security settings\Local policies\Security options
  4. Locate the following policy: User Account Control: Run all administrators in Admin Approval Mode
  5. Set it to Enabled.
  6. Reboot PC.

worked for me