Image Upload error 500 : internal server error

Hello,
i have a problem uploading images it give me 500 : internal server error
but can upload any other files except images
also it was working fine before exporting and importing the data
can anyone please help.
1

Hey, Any update on this?

I had the same problem, I’d appreciate it if there was a way to fix it

@Kha_Le @BNe Did you got the solution?? I am stuck on this.

I tried the following.
Changed client_body_size in nginx cofig.
Added max size in sites.config
Still getting the same error.

Do you have any solution to this?

Did you get the solution?

I am still stuck, anyone got any solution?

Goto Network Panel and Give Traceback :slight_smile:

1 Like

Go to /etc/nginx/conf.d/frappe.conf file

In that file there will be a server block. In server block do the following changes.
Change

client_max_body_size to 50M
client_body_buffer_size to 16M

        # optimizations
        sendfile on;
        keepalive_timeout 15;
        client_max_body_size 50M;
        client_body_buffer_size 16M;
        client_header_buffer_size 1k;

For more information you can refer this blog on medium.
Cannot upload file through Nginx Error 500

“["Traceback (most recent call last):\n File \"apps/frappe/frappe/app.py\", line 95, in application\n response = frappe.api.handle()\n File \"apps/frappe/frappe/api.py\", line 54, in handle\n return frappe.handler.handle()\n File \"apps/frappe/frappe/handler.py\", line 47, in handle\n data = execute_cmd(cmd)\n File \"apps/frappe/frappe/handler.py\", line 85, in execute_cmd\n return frappe.call(method, **frappe.form_dict)\n File \"apps/frappe/frappe/init.py\", line 1622, in call\n return fn(*args, **newargs)\n File \"apps/frappe/frappe/handler.py\", line 223, in upload_file\n return frappe.get_doc(\n File \"apps/frappe/frappe/model/document.py\", line 307, in save\n return self._save(*args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 329, in _save\n return self.insert()\n File \"apps/frappe/frappe/model/document.py\", line 278, in insert\n self.run_method(\"after_insert\")\n File \"apps/frappe/frappe/model/document.py\", line 917, in run_method\n out = Document.hook(fn)(self, *args, **kwargs)\n File \"apps/frappe/frappe/model/document.py\", line 1276, in composer\n hooks.append(frappe.get_attr(handler))\n File \"apps/frappe/frappe/init.py\", line 1612, in get_attr\n return getattr(get_module(modulename), methodname)\n File \"apps/frappe/frappe/init.py\", line 1342, in get_module\n return importlib.import_module(modulename)\n File \"/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/init.py\", line 126, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File \"\", line 1050, in _gcd_import\n File \"\", line 1027, in _find_and_load\n File \"\", line 1006, in _find_and_load_unlocked\n File \"\", line 688, in _load_unlocked\n File \"\", line 883, in exec_module\n File \"\", line 241, in _call_with_frames_removed\n File \"apps/frappe_s3_attachment/frappe_s3_attachment/controller.py\", line 9, in \n import boto3\n File \"env/lib/python3.10/site-packages/boto3/init.py\", line 16, in \n from boto3.session import Session\n File \"env/lib/python3.10/site-packages/boto3/session.py\", line 17, in \n import botocore.session\n File \"env/lib/python3.10/site-packages/botocore/session.py\", line 25, in \n import botocore.configloader\n File \"env/lib/python3.10/site-packages/botocore/configloader.py\", line 19, in \n from botocore.compat import six\n File \"env/lib/python3.10/site-packages/botocore/compat.py\", line 23, in \n from botocore.exceptions import MD5UnavailableError\n File \"env/lib/python3.10/site-packages/botocore/exceptions.py\", line 15, in \n from botocore.vendored.requests.exceptions import ConnectionError\n File \"env/lib/python3.10/site-packages/botocore/vendored/requests/init.py\", line 58, in \n from . import utils\n File \"env/lib/python3.10/site-packages/botocore/vendored/requests/utils.py\", line 26, in \n from .compat import parse_http_list as _parse_list_header\n File \"env/lib/python3.10/site-packages/botocore/vendored/requests/compat.py\", line 7, in \n from .packages import chardet\n File \"env/lib/python3.10/site-packages/botocore/vendored/requests/packages/init.py\", line 3, in \n from . import urllib3\n File \"env/lib/python3.10/site-packages/botocore/vendored/requests/packages/urllib3/init.py\", line 10, in \n from .connectionpool import (\n File \"env/lib/python3.10/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py\", line 38, in \n from .response import HTTPResponse\n File \"env/lib/python3.10/site-packages/botocore/vendored/requests/packages/urllib3/response.py\", line 9, in \n from ._collections import HTTPHeaderDict\n File \"env/lib/python3.10/site-packages/botocore/vendored/requests/packages/urllib3/_collections.py\", line 1, in \n from collections import Mapping, MutableMapping\nImportError: cannot import name ‘Mapping’ from ‘collections’ (/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/init.py)\n"]”
exception
:
“ImportError: cannot import name ‘Mapping’ from ‘collections’ (/opt/homebrew/Cellar/python@3.10/3.10.13/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/init.py)”

Can you please help me here?

Revert to Python 3.9 You are currently using python 3.10 which is the issue. go with

  1. Install Python3.9
  2. Check if python exists using command python3.9 --version

Run Command

bench migrate-env python3.9

how did u solved it

i got same error plz tell me how to solve it