Specs: Rails 4.2.4, Ruby 2.1.9, running puma, EC2 instance in production mode

I have an SSL certificate that I want to install on my server but using techniques like this one yields no results

rails s puma -b 'ssl://'


Instead of a functioning server I get

Puma starting in single mode...
* Version 3.2.0 (ruby 2.1.9-p490), codename: Spring Is A Heliocentric Viewpoint
* Min threads: 0, max threads: 16
* Environment: production
* Listening on tcp://ssl://
* Exiting /home/ec2-user/.rvm/gems/ruby-2.1.9@slideshow/gems/puma-3.2.0/lib/puma/binder.rb:240:in
`initialize': getaddrinfo: Name or service not known (SocketError)

Now my mind is playing with different options. I could continue using puma and somehow make it work. I could switch to a different server gem. Or I could use Amazon's certificate management system (though I'm guessing there are some costs involved with that).

Any help is greatly appreciated, I'm trying to save myself a long and wild goose chase.

  • 2
    ACM (AWS Certificate Manager) doesn't charge for standard certificates. They won't attach to an instance AFAIK, but are easy to associate with an AWS load balancer. I use Let's Encrypt certificates. – Tim Feb 14 '19 at 19:55

The obvious thing to do is to fix the errors in the paths to the certificates. You have used a symbol ~, which has no special meaning in pathnames in Linux. Instead, this is a shortcut used by the Bash shell to substitute the user's home directory. But because you have single quoted the parameter, Bash does not perform the substitution.

You need to specify the path explicitly, not using ~.

And of course, you need to not have TLS certificates or web applications in a user's home directory, but that's another discussion.

  • I appreciate that, I actually fixed the ~ issue shortly after posting this. Still had the same problem. What solved the issue was dropping the rails server command and just running via puma... command. – Randall Coding Feb 18 '19 at 15:59

Found the solution by reading through some of the issue pages on puma's Github page. Apparently we must call puma directly, and not through rails server, despite what was said here in this old stackoverflow answer

The working code is

RAILS_ENV=production rvmsudo -E puma -d -b "ssl://${KEY_PATH}&       
cert=${CERT_PATH}&verify_mode=peer&ca=${CERT_BUNDLE_PATH}" -p 80 

Make sure to turn on config.force_ssl in your production config file as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.