Getting 413 Request Entity Too Largenginx/1.24.0
Hey guys so i have deployed my applications via github, which is laravel app, when i upload images which is only 1.1MB, it said that the request entity too large. How can i solve this? please send me any help since i'm new on deploying and stuff
44 Replies
This is an issue with the default nginx configuration. Your file exceeds the default
client_max_body_size
which can be configured through nginx. I am not 100% sure on how to adjust it within Railway, but adjusting this value would help significantly. Let me see if I can figure it out for you.
This could also be an issue with the php configuration in the container... the php.ini you can change upload_max_filesize
and post_max_size
thanks for replying
btw, how to configure the php.ini? i dont have any file named php.ini, should i create it instead? and pull it to my main branch?
vin is working on a drop in solution, stay tuned
Then let me know if your upload works for you
hey i just lost the solution that u sent me before, could u please resend it?
Brody deleted the message by accident, but could you place a file in the root of your project called
nixpacks.toml
then paste the following in EXACTLY as you see it. Then redeploy and try your upload
okay lemme try it
it wasn’t by accident 🤣
you mean here right
and then i got this
Okay, you can remove it. Back to the drawing board for me
okayy
Wait no. You didn't commit the file properly
You need to copy everything I sent, exactly how I sent it including the
[phases.setup]
ah okayy wait
sorry my bad bro
still failed vin
\
You didn't change anything else in your repo, other than the nixpacks.toml correct?
yes i didnt change anything
And there were no errors before?
no it was successfully deployed
Okay, you can delete the nixpacks.toml file, and in the meantime, can you tell me if this Dockerfile works? Create
Dockerfile
in the root of your repo, and paste EXACTLY how it is here
If this doesn't work, I will have to try something elseokayy, wait for a while, lemme try
is it okay if the docker file using php:8.1 and my composer.json use 8.2?
That should be fine, if it gives you an error, you can change the dockerfile first line to be 8.2-apache
Hmmmm
i changed it into php:8.2-apache, and its now still deploying, at least the build was successful
the deployment was successful, but why am i getting the page expired after uploading the image?
hey its deployed now but the page is expired it said
php artisan serve --host=0.0.0.0 --port=$PORT do i really need this?
it's all good when running in local?
please revert to a working state, no dockerfile, no nixpacks.toml, etc
okay brody, how bout the getting 413?
you had this working at one point before opening this thread, right?
yes, the page is okay, but when the users upload the profile picture that is larger than 1M, the server would return 413
thats fine, please revert to that state
okay
after i revert to that state, when i try to login, it would go back to login form again
the data i entered is correct
please get your app into a state where it works before we try to tackle the file upload issue again
wow it worked
thank you for helping me
what worked
reverting the state
but i still havent figured how to solve the 413
so you are in a position now where you could deploy your code again and it would work (ignoring the file upload issue)
yes that is correct
Solution
place these two files into the root of your project
without them, i can reproduce the 413 error, with then, my file uploads without issue
okay brody, lemme try
thank uuuu sooo much Brody it worked
all hail
thanks also Vin
it means so much to me since this deployment for my final project (pre-grad) haha
keep shining bro
happy to help 🙂