3

I'm working on an app currently and I attempted to replace my webserver WEBrick with puma. The application is currently deployed with Heroku. Also, while doing this I wanted to be able to run my rails s with production. To my understanding, I would need to set the SECRET_KEY_BASE key in my secret.yaml file. I did this while also setting up a SECRET_TOKEN in heroku. To make a long story short, I actually reverted back to WEBrick webserver. But now, when I run rails s production or development, I get the following:

=> Booting WEBrick
=> Rails 4.2.5.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-04-27 13:40:57] INFO  WEBrick 1.3.1
[2016-04-27 13:40:57] INFO  ruby 2.2.0 (2014-12-25) [x86_64-darwin14]
[2016-04-27 13:40:57] INFO  WEBrick::HTTPServer#start: pid=24061 port=3000

When trying to load the page at https://localhost:3000/ I get the following errors in terminal:

[2016-04-27 13:41:09] ERROR bad URI `]n?Q2}N?<\x01H\x00\x00\x1C?+?/̨̩?\x14?\x13?'.
[2016-04-27 13:41:09] ERROR bad URI `dU?\x00\x00\x1C?+?/̨̩?\x14?\x13?'.
[2016-04-27 13:41:09] ERROR bad Request-Line `\x16\x03\x01\x00?\x01\x00\x00?\x03\x03}??4??CN??\x02\x04?4?\x17??\ea??u%?\x06?yڔ\x13?\x00\x00\x1C?+?/̨̩?\x14?\x13?'.
[2016-04-27 13:41:09] ERROR bad Request-Line `\x16\x03\x01\x00?\x01\x00\x00?\x03\x03????3?W\x14kt??0M\x1A#U?"u?Ä??qj?]}??\x00\x00\x1C?+?/̨̩?\x14?\x13?'.
[2016-04-27 13:41:09] ERROR bad Request-Line `\x16\x03\x01\x00?\x01\x00\x00?\x03\x03?f\x1E?V?4?'.
[2016-04-27 13:41:09] ERROR bad Request-Line `\x16\x03\x01\x00?\x01\x00\x00?\x03\x03??C?ݔ\x01\r?OS#?S??Ej?\\\x15\r\x17k\x0Ep?\x1C?"?F\x00\x00\x1C?+?/̨̩?\x14?\x13?'.

And the following in my DOM:

This site can’t provide a secure connection
localhost sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

So obviously I did something when setting up the SECRET_TOKEN/SECRET_KEY_BASE because before it was working and now not a single project of mine can run the rails server. I understand that this is dealing with SSL, but I am unsure where to begin or how to fix this. I have tried and read a lot and have yet to have some luck.

SIDE NOTE: I have created a brand new rails project from scratch and simply tried to run rails s. I have had the same issue. As I commented below, I was having the same issue when trying to run puma as my webserver. I now cannot run a local server on ANY project of mine. This leads me to believe that I have messed something up that applies to my system.

Thank you for any time taken/spent to help me.

FIXED:

Okay, so for whatever reason(something I did I'm sure), when I attempted to visit localhost:3000 it would take me to -> https://localhost:3000 which, as you stated, could not be handled by WEBrick unless configured to do so. My address bar continued to force HTTPS, even if I tried visiting http://localhost:3000. After I cleared my cookies/history...everything is working. I appreciate your help.

Nmk
  • 1,281
  • 2
  • 14
  • 25
Nappstir
  • 995
  • 2
  • 20
  • 38
  • If you're on OS X, [Pow](http://pow.cx) makes Rails a lot more pleasant. – tadman Apr 27 '16 at 20:05
  • Yes, I have used `pow` and still do with almost all my api builds. However, there is a big issue with me not being able to run `rails s` out of the gate on a newly created rails project. I did something to really mess up my ability to run webservers so the solution probably has to be something bigger than switching webservers or using workarounds. – Nappstir Apr 27 '16 at 20:16
  • Remember that neither Pow nor `rails server` can deal with HTTPS out of the box. For that you'll need to layer something in front, like Apache httpd or Nginx. HTTPS is incompatible with HTTP, so they can't share the same port. It's highly unusual to do local development with HTTPS. Without a valid certificate I'm not sure what you're trying to accomplish. – tadman Apr 27 '16 at 20:20
  • I have actually never paid attention to whether `pow` or `rails s` was using HTTPS or HTTP. I always just deployed w/ `heroku` used `rails s` for development. Now it seems that its trying to handle HTTPS and IDK what I did to make it do so or 'revert' it back to the way it originally is... – Nappstir Apr 27 '16 at 20:39
  • @tadman is there a way to reset webrick server of some sort? I think you are on the right track where I did something so that the server is now trying to run under HTTPS – Nappstir Apr 27 '16 at 21:10
  • 1
    It's not the server trying to run under HTTPS, it's your URL that is HTTPS and WebBrick can't and shouldn't have to deal with that. – tadman Apr 27 '16 at 21:19

0 Answers0