user image

Joseph Morgan
Published in : 2022-02-01

[solved] Nginx 413 Request Entity Too Large - Laravel

Laravel

Hello there,
I am facing this error when I try to upload image more than 1MB to my server which is running with Laravel & Nginx 

What Should i do, I tried to update the php.ini & increased the values of 
post_max_size
upload_max_filesize
max_execution_time

and nothing is changing the same error, please help!

Comments

Mohamed Atef Date : 2022-02-01

Best answers

51

Best answers

51

It seems that the error is not from PHP this is Nginx error I suggest that you can update the client_max_body_size from the configuration file by the next steps 

  1. use SSH connection to connect to your server
  2. go to /etc/nginx/sites-available using this command
    cd /etc/nginx/sites-available
  3. see which config file is using probably it will be named with the domain name you are using
  4. consider it's called “default” so you can run this command to edit it 
    sudo nano default (sudo nano domain_name)
  5. then between the server { … } add client_max_body_size 64M;

Like

server {.....client_max_body_size 64M;}

that's all, good luck

Joseph Morgan Date : 2022-02-01

Best solution, you are amazing :) Thanks 

Mayur Tandan Date : 2022-07-21

Hi Joseph,
I am using laravel 5.4 with PHP 7.4. Trying to upload 6 mb file after converting into base64 from from frontend angular using laravel API getting 413 error. Changed nginx conf settings set 120M also changed php.ini settings.
```
upload_max_filesize 100M;
post_max_size 100M;
memory_limit 120M;
```
still getting the same error. what could be the reason.

Mohamed Atef Date : 2022-07-21

Have you changed the client_max_body_size? in the nginx.conf?

server {.....client_max_body_size 64M;}

Mayur Tandan Date : 2022-07-22

Yes, I already changed it.

Mohamed Atef Date : 2022-07-22

Have you restarted the Nginx server? or Apache2?

Mayur Tandan Date : 2022-07-22

Yes, after changing the Nginx setting restarted the Nginx server and after changing the PHP settings restarted the apache server.

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

[solved] All assets in laravel storage returns 404
Publish date: 2021-12-14 | Comments: 2
How to check Laravel version?
Publish date: 2022-04-07 | Comments: 2
Undefined Variable problem on Laravel 9.x
Publish date: 2022-03-06 | Comments: 3
API CORS error in Laravel 9x
Publish date: 2022-08-03 | Comments: 2
How can I use arabic words, paragraphs in the faker?
Publish date: 2022-03-06 | Comments: 1