How to fix 'Too many open files' error in RSpec & Capybara?

Error:

Errno::EMFILE:
       Failed to open TCP connection to 127.0.0.1:9515 (Too many open files - socket(2) for "127.0.0.1" port 9515)

After running ulimit -Sn 10240 in bash, the underlying error becomes visible. For me, this was:

 Failure/Error: expect(page).to have_content 'Some text'
       expected to find text "Some text" in "Some other text"

Ref: https://stackoverflow.com/a/61892983 https://wilsonmar.github.io/maximum-limits/