Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx - 502 Bad Gateway for some ajax requests

Tags:

ajax

php

nginx

I get 502 Bad Gateway for some requests on my server. I get it for some particular AJAX requests but if I replay the failed request in the console, it works (wtf). In nginx/error.log it says

[error] 13867#0: *74180 recv() failed (104: Connection reset by peer) while reading response header from upstream

My website is in PHP. Thanx

like image 658
Michal Artazov Avatar asked Jan 12 '23 06:01

Michal Artazov


2 Answers

I had similar problem on wordpress site. add these lines inside http block of /etc/nginx/nginx.conf file.

fastcgi_temp_file_write_size 10m;
fastcgi_busy_buffers_size 512k;
fastcgi_buffer_size 512k;
fastcgi_buffers 16 512k;

If it still not working also add this line

 client_max_body_size 50M;
like image 158
Tharindu Wickramasinghe Avatar answered Jan 16 '23 21:01

Tharindu Wickramasinghe


I had similar problem with my gitlab setup on nginx. What helped solve my problem was to higher max client's body size by client_max_body_size 50m directive inside http block of /etc/nginx/nginx.conf file.

like image 29
svobol13 Avatar answered Jan 16 '23 20:01

svobol13