I can't upload images to production in cpanel

Hello, I have a django application in production, I can’t upload images but even though everything else works fine.

This is the error I get when trying to upload an image:

Internal Server Error: /admin/pages/about/1/change/
Traceback (most recent call last):
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/core/handlers/base.py", line 171, in _get_response
    response = middleware_method(request, callback, callback_args, callback_kwargs)
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/middleware/csrf.py", line 297, in process_view
    request_csrf_token = request.POST.get('csrfmiddlewaretoken', '')
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 102, in _get_post
    self._load_post_and_files()
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/http/request.py", line 362, in _load_post_and_files
    self._post, self._files = self.parse_file_upload(self.META, data)
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/http/request.py", line 322, in parse_file_upload
    return parser.parse()
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/http/multipartparser.py", line 241, in parse
    for chunk in field_stream:
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/http/multipartparser.py", line 388, in __next__
    output = next(self._producer)
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/http/multipartparser.py", line 520, in __next__
    for bytes in stream:
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/http/multipartparser.py", line 388, in __next__
    output = next(self._producer)
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/http/multipartparser.py", line 451, in __next__
    data = self.flo.read(self.chunk_size)
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/http/request.py", line 391, in read
    return self._stream.read(*args, **kwargs)
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 40, in read
    result = self.buffer + self._read_limited(size - len(self.buffer))
  File "/home/creafzdi/virtualenv/public_html/asesoramarvalencia.com/3.8/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 28, in _read_limited
    result = self.stream.read(size)
SystemError: <method 'read' of 'lsapi_wsgi.InputStream' objects> returned NULL without setting an error
OSError: LSAPI: Socket read/write error
1 Like

Having the issue let me know if you got solution

Hello, I solved the problem by uploading the images in chunks using plupload :slight_smile: @Nuradic

1 Like

I was able to identify that cpanel only allowed me to upload content < 60kb, so each image chunk weighs < 60 kb and this can be configured with plupload.

1 Like

impressive I will try it. thanks

1 Like

Got this same error on my website. Troubleshoot for days yet nothing happened. I believed it was an internal error caused by lsapi which is a LitesSpeed script used by my hosting provider which I don’t have access. Needed support to fix it internally. After a day or two it is working now.

That is a smart solution for Django applications that have templates. But I am developing a Django backend application to be accessed with a REST API using Django Rest Framework. ANd, I am having the same problem. How can I solve the issue?