Django ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

18,942

Solution 1

I have checked in a fix for this in Python: https://github.com/python/cpython/pull/9713

It will be available in the next version of Python 3.7 and later.

Solution 2

ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

If you are working with the videos this happens when you make another request while the video is uploading to the database. I would suggest you to use preload='none' in video tag or block the new requests while video is uploading.

Solution 3

I was making a web application and was facing the same issue in windows 10, python 3.7.6, django 3.0.8. I tried a lot of stuff and i finally found a fix.

I was using a form which called a js function onsubmit which in turn sent a REST call which was getting canceled with the '[WinError 10053] An established connection was aborted by the software in your host machine' error in command prompt.

I added the parameter method='post' and used jQuery.ajax in the js function and i added the event.preventDefault() as well in the function as well as some success and fail callbacks. I don't understand why but now i am not getting the error.

Hope this help anyone using js along with HTML forms until a the issue is root-caused and fixed.

This Github bug is tracking the issue

Share:
18,942
Sushant
Author by

Sushant

Updated on July 20, 2022

Comments

  • Sushant
    Sushant almost 2 years

    I am using django with postgresql, whenever I try to save or delete anything, this error occurs -

    Traceback (most recent call last):
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 138, in run
    self.finish_response()
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
    Not Found: /favicon.ico
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 332, in send_headers
    self.send_preamble()
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 255, in send_preamble
    ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
    [02/Aug/2016 18:30:14] "GET /favicon.ico HTTP/1.1" 404 2044
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 453, in _write
    self.stdout.write(data)
    File "c:\program files (x86)\python35-32\Lib\socket.py", line 593, in write
    return self._sock.send(b)
    ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
    [02/Aug/2016 18:30:14] "GET /api/delete/ HTTP/1.1" 500 59
    ----------------------------------------
    Exception happened during processing of request from ('127.0.0.1', 1712)
    Traceback (most recent call last):
     File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 138, in run
    self.finish_response()
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 332, in send_headers
    self.send_preamble()
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 255, in send_preamble
    ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 453, in _write
    self.stdout.write(data)
    File "c:\program files (x86)\python35-32\Lib\socket.py", line 593, in write
    return self._sock.send(b)
    ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 141, in run
    self.handle_error()
    File "C:\Users\sushant\Desktop\projects\drfapi\venv\lib\site-packages\django\core\servers\basehttp.py", line 92, in handle_error
    super(ServerHandler, self).handle_error()
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 368, in handle_error
    self.finish_response()
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 180, in finish_response
    self.write(data)
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 274, in write
    self.send_headers()
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 344, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
    TypeError: 'NoneType' object is not subscriptable
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
    File "c:\program files (x86)\python35-32\Lib\socketserver.py", line 628, in process_request_thread
    self.finish_request(request, client_address)
    File "c:\program files (x86)\python35-32\Lib\socketserver.py", line 357, in finish_request
    self.RequestHandlerClass(request, client_address, self)
    File "C:\Users\sushant\Desktop\projects\drfapi\venv\lib\site-packages\django\core\servers\basehttp.py", line 99, in __init__
    super(WSGIRequestHandler, self).__init__(*args, **kwargs)
    File "c:\program files (x86)\python35-32\Lib\socketserver.py", line 684, in __init__
    self.handle()
    File "C:\Users\sushant\Desktop\projects\drfapi\venv\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle
    handler.run(self.server.get_app())
    File "c:\program files (x86)\python35-32\Lib\wsgiref\handlers.py", line 144, in run
    self.close()
    File "c:\program files (x86)\python35-32\Lib\wsgiref\simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
    AttributeError: 'NoneType' object has no attribute 'split'
    ----------------------------------------
    

    What happens is whenever a database save\delete command is there, it gets executed twice, first time without errors, second time, throwing this error and hence, save is done twice.

    What I understand is some program is blocking it(as the error says) so I removed the anti-virus that I had but with no conclusions.

    Does anyone have any idea what this is all about?

    Edit: It's a Python bug, reported here

  • Susa
    Susa almost 6 years
    could you give an example for this?
  • Rishi Bansal
    Rishi Bansal over 4 years
    I am using python 3.7.2 but still facing same issue. Any suggestion?
  • Petter
    Petter over 4 years
    NEXT version of 3.7. Your version was released Dec. 24, 2018.
  • Bobort
    Bobort about 4 years
    I tried appending slashes, and it still gives me the error.
  • geekandglitter
    geekandglitter over 3 years
    I was restarting my computer, too, until I discovered it was caused by having more than one tab open in my browser with my django app running.