Rails production mode: SSL received a record that exceeded the maximum permissible length
Asked Answered
J

3

6

Hi I'm not sure if this is supposed to happen, but when I do a RAILS_ENV=production rails server in my terminal and then try to run localhost:3000 it gives me an error:

Secure Connection Failed

An error occurred during a connection to localhost:3000.

SSL received a record that exceeded the maximum permissible length.

(Error code: ssl_error_rx_record_too_long)

I read somewhere that it might be because my url is https://localhost:3000/ instead of http://localhost:3000/ with the "S" after http? but I can't change it since it keeps going to https automatically.

Is this normal? The reason I'm trying to run it in production is because I am getting errors when I try to deploy my app into heroku ( question asked here: Rails + Heroku : ActionView::Template::Error ) so I thought it would help me debug.

Jovial answered 29/10, 2012 at 17:35 Comment(0)
J
7

This error is normal when trying to access Rails via SSL when it is run with rails server, unless you hack the default rails server script to support SSL. You can see this blog post for how to do that. That said, I'd recommend simply not accessing your application via SSL on your local machine.

You probably have a configuration in your Rails app that is redirecting to SSL when you are running the production environment. Try temporarily commenting out that configuration so that you can run in production without needing to configure SSL on your local machine.

Look in production.rb for:

config.force_ssl = true

Or, look in application_controller.rb (or any other controller) for:

force_ssl

Note: they have the same name, but under the hood they work very differently.

Alternatively, you could run Rails on your local machine via some other web server besides rails server, but that is outside the scope of this question, and you would still have to configure it to support SSL. Personally I have nginx (with unicorn) setup on my local machine with a self-signed SSL certificate so that I can easily test SSL-related behavior in my app.

Also, you might consider alternate ways to debug your application besides running it in production on your local machine, but exactly how to do that depends on the nature of the bug you're trying to debug.

Jaquez answered 30/10, 2012 at 6:33 Comment(3)
The link of the blog post you posted seems to be broken. Isn't loading.Passing
@Dhrubo_moy Try gist.github.com/roloenusa/859755/…Jaquez
Great. Thank you so much. I tried commenting out "config.force_ssl = true" line. But still having the SSL_ERROR_RX_RECORD_TOO_LONG error.Passing
G
4

For me config.force_ssl = true was in config/environments/production.rb

Gasiform answered 1/6, 2013 at 12:0 Comment(2)
That is not true Brad. The previous author suggests "production.rb or application_controller.rb". In my case (hoping to help others) "config.force_ssl = true" is set in the file "config/environments/production.rb".Gasiform
also, back then I did not have permissions to add it as a "comment" either.Gasiform
P
0

This error occurred for me when I added my machine's hostname in to /etc/hosts with the same name for ipv4 and ipv6.

So it looked like:

127.0.0.1     localhost MyMachine
::1       ip6-localhost MyMachine

After updating the ipv6 personal machine name to prepend the ip6- then Rails started working.

Peirsen answered 27/8, 2019 at 20:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.