Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simpleton/c2c1c15bd0bba78bff49 to your computer and use it in GitHub Desktop.
Save simpleton/c2c1c15bd0bba78bff49 to your computer and use it in GitHub Desktop.
failed (104: Connection reset by peer) while reading response header from upstream, client:
failed (104: Connection reset by peer) while reading response header from upstream, client:
If you are getting the above error in nginx logs running in from of upstream servers you may consider doing this as it worked for me:
check the ulimit on the machines and ensure it is high enough to handle the load coming in. 'ulimit' on linux, I am told determines the maximum number of open files the kernel can handle.
The way I did that?
modifying limits: for open files:
--------------------------------
add or change this line in /etc/systcl.conf
fs.file-max = <limit-number>
set soft & hard limits in this file for various users: /etc/security/limits.conf
<user-name or group-name or *> soft nofile <limit-number>
<user-name or group-name or *> soft nofile <limit-number> hard nofile <limit-number>
Then reload the system settings withou restarting:
sysctl -p
nginx settings :
--------------------------------
in nginx.conf add/set:
worker_rlimit_nofile <limit-number>
When setting up upstream servers or not, it is a good idea to keep some connections alive when running on HTTP 1.1. Consider adding this to the upstream block on :
keepalive <some-number>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment