user

Joseph Morgan

1 Feb 2022

[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

1 Feb 2022

Best Answer

best answer
githubgithubgithub

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

Replies

Joseph Morgan

1 Feb 2022

Best solution, you are amazing :) Thanks 

Mayur Tandan

21 Jul 2022

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.

Replies

Mohamed Atef

21 Jul 2022

githubgithubgithub

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

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

Mayur Tandan

22 Jul 2022

Yes, I already changed it.

Replies

Mohamed Atef

22 Jul 2022

githubgithubgithub

Have you restarted the Nginx server? or Apache2?

Mayur Tandan

22 Jul 2022

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

© 2024 Copyrights reserved for web-brackets.com