recv() failed (104: Connection reset by peer) while reading response header from upstream

John Doe ·

2292 Views

LinkedIn sharing has not worked for me.

So I checked a URL from LinkedIn’s Post Inspector.

 

 

A 400 error has occurred.

I checked the server error log again.

[error] 4993#4993: *22595 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 1.1.1.1, server: example.com, request: "GET / HTTP/1.1", upstream: "uwsgi://unix://www/webservice.sock:", host: "example.com", referrer: "url"

This snippet is for future me. Most answers for this problem you'll see are related to PHP. This issue is related to the buffer size in the uWSGI. Probably your requests have a long query parameters and cookies.

 

First, I added the following code to nginx.conf:

reset_timedout_connection on;
keepalive_requests 1000;
send_timeout 30;
server_names_hash_max_size 2048;

#access_log /var/log/nginx/access.log;
access_log off;
log_not_found off;

but it still has not worked.

 

One setting that occasionally needs to be adjusted is UWSGI_BUFFER_SIZE. The default value is 4096. If you plan to receive relatively big requests, you'll need to change this parameter value. You can tune it up to 65535.

I do it in my application config uwsgi ini file. ( basically ini file is in /etc/uwsgi/ )

buffer-size=32768

 

* If you want to show an OG image, then you have to resize the image to 1200 px, etc.

My image was 4032x3024, and it didn't show up.

 

Now everything works fine. :)

 

Ref.

abstractkitchen.com uWSGI. recv() failed (104: Connection reset by peer) while reading response header from upstream Posted by Dmitry Updated on December 04, 2022 python uwsgi error snippet nginx [error] 4993#4993: *22595 recv() failed (104: Connection re
Divio Documentation Contents Menu Expand Light mode Dark mode Auto light/dark mode Hide navigation sidebar Hide table of contents sidebar Toggle site navigation sidebar Divio Documentation Toggle Light / Dark / Auto color theme Toggle table of contents si

https://yoast.com/help/linkedin-sharing-not-working/

I am running uwsgi in emperor mode uwsgi --emperor /path/to/vassals/ --buffer-size=32768 and getting this error invalid request block size: 21327 (max 4096)...skip What to do? I also tried -b 32768.
my reference: https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/uwsgi/ my project name: 'mysite' my directories: I create 'uwsgi.ini'. then, I written in ini file. [uwsgi] chdir=/var/ww...

 

python uwsgi nginx