CodexBloom - Programming Q&A Platform

Rails 7: implementing ActiveStorage Uploads Timing Out for Large Files on Heroku

πŸ‘€ Views: 21 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-08
ruby-on-rails activestorage heroku Ruby

I'm getting frustrated with Hey everyone, I'm running into an issue that's driving me crazy... I'm experiencing an scenario with file uploads using ActiveStorage in a Rails 7 application hosted on Heroku. When trying to upload large files (around 50MB), the upload process frequently times out with a `Net::ReadTimeout` behavior. The log indicates that the request is taking too long, leading to a 504 Gateway Timeout from Heroku. I've already tried increasing the `web.timeout` setting in my Heroku configuration and also optimized the connection settings in my `storage.yml` file, but that hasn't resolved the scenario. I've set the ActiveStorage service to use Amazon S3, and here’s a snippet of how my `storage.yml` looks: ```yaml amazon: service: S3 access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %> secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %> region: <%= ENV['AWS_REGION'] %> bucket: <%= ENV['AWS_BUCKET'] %> upload_options: timeout: 600 ``` I've confirmed that my environment variables are set correctly. Additionally, I've tried uploading the files locally, and the uploads work fine without any timeouts. This makes me think the scenario could be related to how Heroku handles file uploads, especially for larger files. I've also considered implementing background processing for the uploads using Active Job, but I'm unsure if that would be a suitable approach for large file handling. Has anyone faced a similar scenario with ActiveStorage on Heroku? Are there any specific configurations or workarounds you recommend to handle larger file uploads without running into timeout errors? My development environment is Windows. Any ideas what could be causing this? I'm on CentOS using the latest version of Ruby. Could this be a known issue? For reference, this is a production desktop app. I'd love to hear your thoughts on this.