[FIXED] Running Flask raises "WinError 10038"

Issue

Running a simple Flask app raises OSError: [WinError 10038] An operation was attempted on something that is not a socket. The page is not served in the browser. What does the error mean? How do I fix it?

from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run(debug=True)
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 294-294-951
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\site-packages\werkzeug\serving.py", line 670, in inner
    fd=fd)
  File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\site-packages\werkzeug\serving.py", line 564, in make_server
    passthrough_errors, ssl_context, fd=fd)
  File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\site-packages\werkzeug\serving.py", line 474, in __init__
    socket.SOCK_STREAM)
  File "C:\Users\kdalal\AppData\Local\Continuum\Anaconda3\lib\socket.py", line 460, in fromfd
    nfd = dup(fd)
OSError: [WinError 10038] An operation was attempted on something that is not a socket

Solution

This issue was fixed in Werkzeug 0.12.1. Upgrade to the latest version:

pip install -U werkzeug

Answered By – Andrejs Cainikovs

Answer Checked By – Robin (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published