I'm making a lot of API requests to a Rails 5.0(.6) app running locally. It inconsistently fails with the Rack error:
RuntimeError: failed to get urandom
The backtrace is to the SecureRandom module, not in the application (specifically the uuid
method). From there it is in ActionDispatch::RequestId. Unfortunately, the full backtrace is gone from my terminal history and does not show up in the logs (since it occurs outside Rails).
From the many requests that are working and the fact that it fails in different places, I'm guessing that it is due to some local system limitation.
After attempting a couple of different fixes, I eventually discovered that the issue was my open files limit. To check it, run ulimit -n
in a terminal. Mine was set to 256.
I followed the instructions in this article: https://wilsonmar.github.io/maximum-limits/
The specific instructions start at the "Sierra and newer versions" header and go to "Their permissions need to be “-rw-r–r–”, set by sudo chmod 644." under #5. After adding the files and changing ownership and permission, I restarted and the open file limit is now 524288.
I now have no further issues with rapid API calls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With