Rails production mode: SSL received a record that exceeded the maximum allowable length

Hi, I'm not sure if this should happen, but when I do 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 this could be because my url is https://localhost:3000/ instead of http://localhost:3000/ s "S" after http? but I can’t change it since it automatically goes to https.

This is normal? The reason I try to run it during production is because I get errors when I try to deploy my application in heroku (question here: Rails + Heroku: ActionView :: Template :: Error ), so I thought that this will help me debug.

+4
source share
3 answers

This error is normal when trying to access Rails via SSL when starting from rails server , unless you crack the default rails server script to support SSL. You can see this blog post on how to do this. However, I would recommend just not accessing your application via SSL on your local machine.

You probably have a configuration in your Rails application that redirects SSL when you start the production environment. Try temporarily commenting on this configuration so that you can run it without having to configure SSL on your local machine.

Take a look at 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 differently.

Alternatively, you can run Rails on your local computer using a web server other than rails server , but this is beyond the scope of this question, and you still have to configure it to support SSL. Personally, I have a nginx installation (with a unicorn) on my local machine with a self-signed SSL certificate so that I can easily test the SSL related behavior in my application.

In addition, you can consider alternative ways of debugging your application, in addition to launching it during production on your local machine, but exactly how to do this depends on the nature of the error you are trying to debug.

+6
source

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

+4
source

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

So it looked like this:

 127.0.0.1 localhost MyMachine ::1 ip6-localhost MyMachine 

After updating the ipv6 personal computer name, adding ip6- , Rails started to work.

0
source

Source: https://habr.com/ru/post/1442821/


All Articles