Question

File Upload Timeout Rails/Paperclip

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?


Submit an answer

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.