Nginx Error: "client sent invalid method while reading client request line"


I am running into an error with my Nginx config after following a tutorial on deploying Rails w/Nginx, Puma, and Capistrano.

New versions of the app deploy successfully to the server, however, when I request the droplet’s IP address, I get the following error (according to the Ngninx error log):

2019/11/26 02:49:35 [info] 11483#11483: *9 client sent invalid method while reading client request line, client:, server: _, request: "??"

How do I go about debugging this error?

Below is my Nginx config:

upstream puma {
  server unix:///home/deploy/apps/modernpricing/shared/tmp/sockets/modernpricing-puma.sock;

server {
  listen 80 default_server;
  listen 443 default_server;
  server_name _;
  ignore_invalid_headers on;

  root /home/deploy/apps/modernpricing/current/public;
  access_log /home/deploy/apps/modernpricing/current/log/nginx.access.log;
  error_log /home/deploy/apps/modernpricing/current/log/nginx.error.log info;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;

  try_files $uri/index.html $uri puma;
  location puma {
    proxy_redirect off;

    proxy_pass http://puma;

  error_page 500 502 503 504 /500.html;
  client_max_body_size 10M;
  keepalive_timeout 10;

And here’s the /etc/nginx/nginx.conf file

user www-data;
worker_processes auto;
pid /run/;
include /etc/nginx/modules-enabled/*.conf;

events {
	worker_connections 768;
	# multi_accept on;

http {

	# Basic Settings

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	# SSL Settings

	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;

	# Logging Settings

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	# Gzip Settings

	gzip on;

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

	# Virtual Host Configs

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hey @KDSys, thanks for offering your help here. I appreciate it.

It looks like my issue was rails-specific as I was able to get past this error by changing force_ssl = true to force_ssl = false in my config/environments/production.rb file.

Of course, the other option is to enable SSL for nginx and the app. That’s up next :)

your are missing ssl in:

  listen 443 default_server;

it should be:

  listen 443 ssl default_server;
Site Moderator
Site Moderator badge
November 26, 2019

Hi @jmarbch,

I have a few suggestions to help you resolve the issue. First one is quite the long shot however you didn’t specify a server_name in your server block.

Additionally, if you try with a blank index.html file is the same error returned? I’m asking as I’ve seen this issue before and it was actually being caused by the application rather than a problem on the server level.

Regards, KDSys

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel