Comments (29)
For what it's worth, I got this error when I mistakenly made requests to localhost/127.0.0.1 with HTTPS (I hadn't set this up) instead of HTTP. I was using Puma.
from puma.
I had this happening for a health check, because the the rails app was configured with config.force_ssl = true
, but the check was bypassing the load balancer terminating ssl, so the check received a redirect to something like https://localhost:5000/ping causing the error.
I had to do some low-level debugging with wireshark to find the issue, so maybe this helps others.
The solution in this case was to add a request header X-Forwarded-Proto: https
to the health checks.
from puma.
@vanboom
I solved this problem by replacing puma on thin server
from puma.
When i use http://localhost:3142/api/v1/users
got the same error HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
, but access 127.0.0.1:3142/api/v1/users
is ok.
from puma.
What was the request? The parser failed because there was a field that was 80k, which is the expected behavior.
from puma.
@wxmn I need more information about this issue to be able to act on it.
from puma.
Got same error today:
2012-10-11 14:54:32 +0200: HTTP parse error, malformed request (): #<Puma::HttpParserError: HTTP element FIELD_VALUE is longer than the 80 * 1024 allowed length.>
2012-10-11 14:54:32 +0200: ENV: {"rack.version"=>[1, 1], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"1.6.3", "GATEWAY_INTERFACE"=>"CGI/1.2"}
---
2012-10-11 14:54:32 +0200: HTTP parse error, malformed request (): #<Puma::HttpParserError: HTTP element FIELD_VALUE is longer than the 80 * 1024 allowed length.>
2012-10-11 14:54:32 +0200: ENV: {"rack.version"=>[1, 1], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"1.6.3", "GATEWAY_INTERFACE"=>"CGI/1.2"}
---
2012-10-11 14:54:48 +0200: HTTP parse error, malformed request (): #<Puma::HttpParserError: HTTP element FIELD_VALUE is longer than the 80 * 1024 allowed length.>
2012-10-11 14:54:48 +0200: ENV: {"rack.version"=>[1, 1], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"1.6.3", "GATEWAY_INTERFACE"=>"CGI/1.2"}
---
Switched from Unicorn to Puma. On Unicorn the app runs without problems. I got there nothing special. Only using ActiveAdmin for apps administration interface. The app is also connected to Solr server through Sunspot gem. Any ideas? If you think I can provide you with more information, please, tell me where to look or what you need. Thanks!
from puma.
What were the HTTP requests? I don't have any ability to replicate the bug right now.
from puma.
The output indicates that puma thinks there is an 80k header value, is that possible in your application?
from puma.
Can you please tell me how to find it out? I am sure I don't modify headers anywhere in the app (not sure about gems).
from puma.
The easiest way is to use dev tools in your browser to look at the request and then paste it to me.
from puma.
Google Chrome gives me "No data received" and Firefox "The connection was reset". I can get any information from both Chrome's developers tools and Firebug. If I try curl
my localhost:port, it raises "Empty reply from server". Any other ideas?
from puma.
This only happens when config.threadsafe!
is uncommented AND connecting via SSL. From the other logs it seems like that to be the case as rack.multithread
is true in both cases. Not sure if they are using SSL though.
from puma.
Actually, I got this error with config.threadsafe!
commented out and was running puma in development mode. Never tried connecting to it using SSL.
from puma.
I had the same experience as @DaveTsunami, I got this error running in development mode. I had config.threadsafe!
defined in my production.rb file only, and it wasn't until I also added it to development.rb did the error go away.
from puma.
I'm getting this error and it's todo with characters it doesn't like passed in the url. Add % to your url and you'll be able to reproduce this error.
from puma.
I am getting this error in my Rails 4/Ruby 2 app with a DELETE
request and a very basic query:
http://my-app.dev/api/widgets/3362107/claim
Log:
13:34:46 web.1 | Started DELETE "/api/widgets/3362107/claim" for 127.0.0.1 at 2013-10-11 13:34:46 -0400
13:34:46 web.1 | Processing by Api::ClaimsController#destroy as */*
13:34:46 web.1 | Parameters: {"widget_id"=>"3362107"}
13:34:46 web.1 | Completed 200 OK in 86ms (Views: 78.0ms | ActiveRecord: 0.6ms)
13:34:46 web.1 | 2013-10-11 13:34:46 -0400: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
13:34:46 web.1 | 2013-10-11 13:34:46 -0400: ENV: {"rack.version"=>[1, 2], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"2.5.1", "GATEWAY_INTERFACE"=>"CGI/1.2"}
13:34:46 web.1 | ---
from puma.
It is possible to log the error's requests (by modifying puma)? I'm also experiencing a similar issue in Rails 4.0.1, Ruby 2.1.0-preview1 but I can't reproduce through a browser, as I have no clue which path the client is trying to hit.
I only get this:
HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
ENV: {"rack.version"=>[1, 2], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"2.6.0", "GATEWAY_INTERFACE"=>"CGI/1.2"}
from puma.
Same happens to me while issuing DELETE requests via ajax. Riding Ruby 2 with Rails 3.2.15.
01:34:14 web.1 | Started DELETE "/signout" for 127.0.0.1 at 2013-11-20 01:34:14 +0000
01:34:14 web.1 | Processing by SessionsController#destroy as */*
01:34:14 web.1 | WARNING: Can't verify CSRF token authenticity
01:34:14 web.1 | User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 5 LIMIT 1
01:34:14 web.1 | (0.1ms) BEGIN
01:34:14 web.1 | (0.1ms) COMMIT
01:34:14 web.1 | Completed 204 No Content in 8.4ms (ActiveRecord: 0.7ms)
01:34:14 web.1 | 2013-11-20 01:34:14 +0000: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
01:34:14 web.1 | 2013-11-20 01:34:14 +0000: ENV: {"rack.version"=>[1, 1], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"2.6.0", "GATEWAY_INTERFACE"=>"CGI/1.2"}
01:34:14 web.1 | ---
from puma.
Is there a flag we can use to have Puma dump the request to stdout/stderr? If there was, I suspect it would make resolving these issues simpler.
from puma.
Also discovered that I got the error with an https url - where ssl isn't set up locally.
from puma.
I got the same "HTTP parse error, malformed request" errors. I wanted Sinatra, Puma, and SSL for a test server. The following code gave me the errors.
Rack::Handler::Puma.run(SinatraApp, rack_opts) do |server|
ctx = Puma::MiniSSL::Context.new
ctx.key = ENV['SSL_KEY']
ctx.cert = ENV['SSL_CERT']
ctx.verify_mode = Puma::MiniSSL::VERIFY_NONE
server.add_ssl_listener(rack_opts[:Host], rack_opts[:Port], ctx)
end
The Puma Rack Handler had the follow lines:
server.add_tcp_listener options[:Host], options[:Port]
server.min_threads = min
server.max_threads = max
yield server if block_given?
Because the yield
came after the add_tcp_listener
, the code called server.add_ssl_listener
too late. The add_tcp_listener
had already bound to the port, I think.
To fix it, I just changed the port for the ssl listener.
from puma.
@lloydmeta you saved my day, Thanks! I was calling localhost over https
from puma.
I'm using ruby 2.1.2p95
, rails 4.1.8
, puma 2.9.2
. For the following plain GET
request
http://localhost:3000/download/files/%D7%A4%D7%A8%D7%95%D7%99%D7%A7%D7%98%2020132%20personal%20ECG%20%
I'm getting
2015-02-05 17:36:30 +0200: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2015-02-05 17:36:30 +0200: ENV: {"rack.version"=>[1, 2], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"text/plain", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"2.9.2", "GATEWAY_INTERFACE"=>"CGI/1.2", "REQUEST_METHOD"=>"GET"}
---
Nothing fancy, just simple GET
from puma.
@gshilin please open a new issue with the information about how you made the request.
from puma.
For others hitting this page as a result of a https error. You are more than likely specifying tcp:// instead of ssl:// as the binding address:
e.g.
bundle exec puma config.ru -b 'tcp://0.0.0.0:3456?key=/path/to/key.key&cert=/path/to/cert.crt'
instead of
bundle exec puma config.ru -b 'ssl://0.0.0.0:3456?key=/path/to/key.key&cert=/path/to/cert.crt'
from puma.
Thanks for the help about changing the binding address to ssl! However, when I configure with ssl://... I receive this error when my client tries to connect...
Rack app error: #<TypeError: no implicit conversion of Puma::MiniSSL::Socket into Integer> /rails_apps/helphub/vendor/bundle/ruby/2.1.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:762:in
attach_fd'`
I am using the private .key file I generated when applying for my certificate, and the .crt file that was given to me by Comodo. Thanks!
from puma.
Hi
i'm facing this issue with puma gem, Can anyone help out me to fix this issue
=> Booting Puma
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run rails server -h
for more startup options
=> Ctrl-C to shutdown server
Puma starting in single mode...
- Version 3.4.0 (ruby 2.3.1-p112), codename: Owl Bowl Brawl
- Min threads: 0, max threads: 16
- Environment: development
- Listening on tcp://localhost:3000
Use Ctrl-C to stop
2016-11-08 11:03:34 +0530: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2016-11-08 11:03:34 +0530: 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.4.0 Owl Bowl Brawl", "GATEWAY_INTERFACE"=>"CGI/1.2"}
---
2016-11-08 11:03:34 +0530: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2016-11-08 11:03:34 +0530: 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.4.0 Owl Bowl Brawl", "GATEWAY_INTERFACE"=>"CGI/1.2"}
---
2016-11-08 11:03:34 +0530: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2016-11-08 11:03:34 +0530: 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.4.0 Owl Bowl Brawl", "GATEWAY_INTERFACE"=>"CGI/1.2"}
---
2016-11-08 11:03:34 +0530: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2016-11-08 11:03:34 +0530: 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.4.0 Owl Bowl Brawl", "GATEWAY_INTERFACE"=>"CGI/1.2"}
---
2016-11-08 11:03:34 +0530: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2016-11-08 11:03:34 +0530: 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.4.0 Owl Bowl Brawl", "GATEWAY_INTERFACE"=>"CGI/1.2"}
---
2016-11-08 11:03:34 +0530: HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>
2016-11-08 11:03:34 +0530: 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.4.0 Owl Bowl Brawl", "GATEWAY_INTERFACE"=>"CGI/1.2"}
---
from puma.
@pavan461 make sure not to use https://
in development, or if you do configure it appropriately.
from puma.
Related Issues (20)
- Puma and Puma Dev Linux issue
- Phased-Restart Causes Action Cable Connection Loss on Rails App Restart HOT 3
- Add a hook for "before shutdown" HOT 6
- Systemd watchdog kills puma during hot restart. HOT 4
- NoMethodError: undefined method `release' for Rack:Module error at "rails s" initialization time HOT 5
- Staging environment, request.ENV['HTTP_HOST'] displays 2 urls when it should be a single url HOT 1
- HttpParserError raised when body (chunk) exceeds 4096 bytes does not end with "\r\n" HOT 4
- undefined method `log_writer' for #<Puma::Launcher on usin plugin :solid_queue in puma HOT 1
- `TestWorkerGemIndependence#test_changing_nio4r_version_during_phased_restart` fails in head builds
- Option to restrict cipher suites for TLS1.3
- Requests with a caret (`<` or `>`) in a query parameter raise a `Puma::HttpParserError` HOT 10
- Random freezes in dev mode
- Puma doesn't start the Rails app after run
- "undefined method `on_booted` for nil:NilClass" on "pumactl start" HOT 2
- Large number of workers are booting too long or not booting the first time HOT 4
- What options are not available when using `rails s`? HOT 1
- MAX_CHUNK_HEADER_SIZE = 4096 is too small for podman HOT 6
- Puma config get evaluated twice with pumactl HOT 3
- question about puma architecture
- Windows - Puma compiled without ssl support HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from puma.