3

After a code break, I got this following error. Then I shut down the server using ctl + c and ensured that there is no process running of ruby or rails. Yet when I try to run server it says the same error:

2017-01-03 13:08:24 +0600: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2017-01-03 13:08:24 +0600: ENV: {"rack.version"=>[1, 3], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"puma 3.6.0 Sleepy Sunday Serenity", "GATEWAY_INTERFACE"=>"CGI/1.2"}
sadaf2605
  • 7,332
  • 8
  • 60
  • 103
  • I know this is over a month old, but you should check that you are connected with http and NOT https. – troxwalt Mar 01 '17 at 18:51

2 Answers2

5

Here are some possible solutions.

  1. Make sure you are connecting through http://localhost:3000 and not https://localhost:3000.

  2. If the browser redirects to HTTPS, try clearing your browser cache and cookies.

  3. If the browser still redirects to HTTPS and it's Google Chrome, try this solution that addresses an HSTS problem: https://stackoverflow.com/a/28586593

  4. Make sure you do not have the production environment (if that's what you're serving) forcing HTTPS. If that's the problem, comment this out:

in config/environments/production.rb

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
  config.force_ssl = true
Community
  • 1
  • 1
Toma Nistor
  • 786
  • 10
  • 18
  • In `config/environments/production.rb` you may also need to set `Rails.application.routes.default_url_options[:protocol] = "http"` – htmlboss Mar 19 '21 at 14:53
0

I had this issue when I accidentally visited localhost:3000, while my localhost project is configured in Nginx to have an TLS certificate and a domain name in /etc/hosts.

Nuha
  • 314
  • 1
  • 3
  • 15