0

Am trying to create a custom error handling page for production, when am working with local project I noticed am getting error 500 for most of the pages, except few page.

ERROR I get is

Exception occurred during processing of request from ('127.0.0.1', 52141)
Traceback (most recent call last):
  File "E:\Dev\Python\lib\socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "E:\Dev\Python\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "E:\Dev\Python\lib\socketserver.py", line 720, in __init__
    self.handle()
  File "e:\Dev\REPOS\2021 PROJECTS\cognizance_cms\.env\lib\site-packages\django\core\servers\basehttp.py", line 174, in handle
    self.handle_one_request()
  File "e:\Dev\REPOS\2021 PROJECTS\cognizance_cms\.env\lib\site-packages\django\core\servers\basehttp.py", line 182, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "E:\Dev\Python\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

I have followed all the steps properly and my custom 500 page loads, but the pages such as login which used to work gets error 500.

If more input his needed let me know I'll add them. I have referred most of the issues raised, nothing seems to be conclusive.

I tried:

# settings.py

DEBUG = False

ALLOWED_HOSTS = ['*']

as a hotfix. I know it should not be done, still it didn't work

# views.py in project directory

def error_404_view(request,exception):
    return render(request,'404.html')

def error_500_view(request):
    return render(request,'pages/500.html')
# urls.py in project

handler404 = 'pages.views.error_404_view'
handler500 = 'pages.views.error_500_view'

Tejas
  • 35
  • 1
  • 10
  • I have no idea, why some pages load and some don't – Tejas Mar 27 '21 at 07:21
  • "_when am working with local project I noticed am getting error 500 for most of the pages_" implies you set `DEBUG = False` in development? Most likely the errors you get are because of static / media files. Django won't serve static files when `DEBUG = False` (implies you are using a production server). – Abdul Aziz Barkat Mar 27 '21 at 07:25
  • @AbdulAzizBarkat any fix? am totally new to this – Tejas Mar 27 '21 at 07:48
  • Test the custom 500 page, etc. on a staging environment if you must. If you just want to see how they look just add an extra url for now and go to that url to see how the page would look. Don't set `DEBUG = False` during development. If you must do something like that without setting up some server there are some solutions people use like [whitenoise](http://whitenoise.evans.io/en/stable/) to serve static files. – Abdul Aziz Barkat Mar 27 '21 at 07:53
  • @AbdulAzizBarkat I assume that it it's not issue with static files as my project is already configured with whit noise. I'll try to re explain the issue am facing. before I changed to `DEBUG=FALSE` all the pages loaded properly, when I changed `DEBUG=TRUE` only few pages load properly, whilst others get 500 error code. Do I need to provide any more inputs? – Tejas Mar 27 '21 at 08:54
  • https://stackoverflow.com/questions/14304658/c-sharp-an-established-connection-was-aborted-by-the-software-in-your-host-machi – Ivan Starostin Mar 27 '21 at 11:03

0 Answers0