I am trying to upload pictures using the paperclip gem and Ruby on Rails. Everything works great except when I try to upload larger files (~5MB), when the application times out.
I’ve set the unicorn.rb config file to have a timeout of 120, while the production database.yml file also has a timeout of 120,000 milliseconds. I’ve also restarted unicorn using service unicorn restart. However, even with these updates, the application still times out - in roughly 5 seconds.
The web application is for a very low-traffic webpage, with only one or two people uploading these types of files occasionally. So, I’m not particularly worried about the performance impact that this functionality might have. Does anyone have any idea what other choke point might be triggering a 5 second timeout error like this?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Okay, figured it out thanks to Chrome (I tend to test in Firefox) which granted me a far more lucid error page:
Nginx: 413 Request Entity Too Large Error
Turns out that I needed to update the timeout and max body size for NGINX. A solution to this is at: http://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/
In my case, using console, I:
SSH into the /etc/nginx folder and type into the console
nano nginx.conf
Iniside of the file, I changed
keepalive_time 120;
Inside of the http section, I also added
``client_max_body_size 15M ```
Then I saved the file and exited back to SSH, where I restarted NGINX via
service nginx restart
service unicorn restart
I’m unsure if restarting unicorn was necessary, but when I do changes like this, I figure it’s a good idea to restart the server. In any event, the program is now happy.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.