Fix 413 Request Entity Too Large Error
After I deployed my web app online, when I tried to upload a PDF file to store in AWS S3 bucket, I received the 413 error as below.
The 413 request entity too large error means that a client has sent a request to a web server but the request is too large for the server to process. Normally, there is an HTTP request size limit has been setting for a server. So, if the request is over the limit, you will get the 413 error.
To solve the issue, you should modify the request size limit to avoid the error.
In my case, Nginx as my web server. The configuration file for NGINX needs to be modified. Normally, the config file is located at /etc/nginx/nginx.conf. You can add one line to change the request size limit:
client_max_body_size 100M;
This line should be located inside of http section. So, the default nginx.conf file should be modified as follow:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
client_max_body_size 100M;
include /etc/nginx/conf.d/*.conf;
}
Then, restart the Nginx server with the new config file. The 413 error will be solved.