Today to my grate surprise I got “502 Bad Gateway” error while trying to open some specific URL on my web site:
I took a look at the Nginx log file located in /var/log/nginx/ directory on my machine and seen the following:
2012/09/17 16:48:47 [error] 15421#0: *16 upstream sent too big header while reading response header from upstream, client: 192.168.1.5, server: milomag.ru, request: “GET /store/rastitelnie-extrakty HTTP/1.1”, upstream: “fastcgi://unix:/var/run/www-beauty.sock:”, host: “milomag.ru”, referrer: “…”
After doing a simple Google search I solved the problem by adding two lines to Nginx configuration file /etc/nginx/nginx.conf :
http { ... fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; ... }
I am not sure that it is absolutely necessary, but each time I install Nginx I add this to /etc/nginx/nginx.conf, at least in versions 1.1.19 on Ubuntu 12.04 and 1.10.3 on Ubuntu 16.04 this works fine:
http { #My custom settings fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; client_max_body_size 24M; client_body_buffer_size 128k; ... }
Without this settings I got ‘502 Bad Gateway error’ while trying to list products or orders in Joomla 1.5/VirtueMart administrative panel.
thanks for this. had the same prob. fixed my prob also.
solved the problem
i fix error
This also solved the problem Nginx 502 Bad Gateway error on my site
Ohh.. how nice. But it is too technical for me. Can u please let me have a step by step guidance? I have Internet Explorer 7 and use Windows Vista Home Edition.
Thnx in advance
Hello! You need Ubuntu Linux, not Windows 🙂 Seriously, the “502 Bad Gateway” error happens on the web server, so it doesn’t matter what OS you’re running and what browser you’re using.
This magically solved my problem. I thought it was about joomla internal rewrite engine conflicting with nginx configuration and spent hours trying to figure out the solution from that angle.
lol, so if i see this when visiting a website (wich isn’t mine) this website just totally crashed right .___.
I’m not sure about “totally crashed”, but I can say with certainty that it does not work at the moment 🙂
Works great! realy helps. Thank You!
doesn´t solved my problem… but thx for help
Did not solve my 502 error either, so there must be a couple of solutions. This is obviously one of them though. Thanks for posting a solution – even if it didnt solve mine !
Good morning,
I am also having this message when I try to log to my Warez-bb account:
“502 BAD gateway – NGINX”
I want to try your solution but I am unable to finde the “path” /etc/nginx/nginx.conf
How do I access NGINX configruation page? I’m running W7 64bit.
Thanks!
Regards
Hello! I suppose something temporarily wrong with the web site you are trying to open.
You can’t fix this on your (Browser) side. It’s a Server issue.
Seems to have done the trick,
Keep up the good work, stay safe!
Paul 🙂
It got rid of the problem… Thanks!
This also solved the problem Nginx 502 Bad Gateway error on my Magento site.
Thank You!
Is there a reason why this has started happening recently on various sites where it never happened previously?
Is there anything I can do about it as a users of the sites?
Hello, Claude! One of the possible reasons is a software update or some changes in Nginx configuration. If you have the access to Nginx configuration files there are a lot of things you can do.
Fixed my problem also! Tanks and success!
I faced “502 Bad Gateway : ngix” error at my site. To solve this problem, I used this “/etc/nginx/nginx.conf” at command. But When I entered it, it appear this error “blush : access denied for /etc/nginx/nginx.conf”.
If so , I can’t continue to run your following code
http {
…
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
…
}
How can I fixed this error. Please can you give your advice.
Probably you need the root access to “/etc/nginx/nginx.conf”, try sudo -s or something like this.
hi dmitriano,
thanks for the simple and great solution. it worked !!
Thank you
By reading your articles I’ve solved my own
Fixed my problem!! Thanks a lot
Fixed the problem, but next to how much should i increase the value?
Fixed my problem too – thanks!
This fixed my 502 gateway problem. Thanks i found this website.
I’m having this problem on my iPhone 4S. Any solution?
Thanks, i fixed that
I had the same problem and There was no directory or config file as stated above, What worked for me was:
going to command com, cmd.exe and doing DNS flush:
How to clear dns cache on Windows XP, 2000, Vista or Windows7 OS?
Open the Windows Start menu.
Go to Run.
If you do not see the Run command in Vista, search for “run” in the Search bar.
In the Run text box, type: ipconfig /flushdns
Press Enter or Return, and dns cache of Windows OS will be flushed.
How to clear dns cache on MacOS?
Go to Applications.
Go to Utilities.
Open the Terminal application.
Type: dscacheutil -flushcache
Press Enter or Return, and your MacOS DNS cache will be cleared.
Thanks, i fixed that!!!!
Thanks a lot. Fixed my problem.
Ali, that did not work.
I solved this problem by click on “rebuild” in category menu.
it’s work in my joomla 3.2 website
http://www.happykorat.com
Fixed the problem. Thank you very much
Hey guys! Today something wierdo happend to my site. i got error like this Bad Gateway or something http://www.asysteo.pl any idea what could happend?
i recently updated php version so maybe thats a problem?
Thanks, this solved my problem too. No way I would have fixed this on my own.
I want to kiss you! Thank you so much! 😀
still facing same issue when i was added above code
Please help me on this issue
Take a look at Nginx log files. Is there something suspicious?
Cant fix it. Help. Im using safari browser on iphone
Thx. This turned out to be the issue on my server as well.
Fixed. had the same issue. Thank you!
Thank you so much this really worked
Thank you, thank you, thank you!
2 years and finally solved.
A wensite I visit seems to habe this problem. I might try to contact them and link them to this.
Alot of other websites I surf have this problem, too. Tney all seem to be using nginx because the error page indicates that. Also, the errors seem to last one minute or so then correct themselves, so they may have not seen it in action.
So in cases like these, the only solution available client-side is to drop an email to the site’s webmaster, as they are the only ones that can fix things on their side. Annoying, but it may help the owner of your favorite site improve their reliability.
Still gold!
Slightly different problem, but I’ll leave here the solution for future reference:
Error 502 on magento customer account creation.
Nginx error reporting a 104 php gateway error
/var/log/php-fpm.log reports segmentation fault.
Solution: restart php-fpm with ‘sudo service php-fpm restart’
i had similiar issue, this tutorial solve few 502 problem but im still get 502 error every time saving in wordpress menu settings
502 Bad Gateway
nginx/1.4.6 (Ubuntu)
Getting error
That did the trick for me too. Thanks!
Hello!
I was trying to open the COUCHSURFING site (www.couchsurfing.com) in my laptop and tables, and I got this message:
502 Bad Gateway
nginx/1.10.3 (Ubuntu)
It seems that the way you solved your problem has helped many others. The problem is that I have limited knowledge regarding How, Where or What to type to solve it (you mentioned adding couple of lines) or configurating (or re-configurating) that error message.
… would you mind helping me in a more detailed way?
Not sure if I had to fill out in the requested DATA if you needed the website where I found the 502 Bad Gateway (I don’t have a website myself).
Thanks!
Hello!
It looks like a temporary misconfiguration at the server side, but not on your laptop. Wait a while and try again.
solved my problem within minutes
brilliant!!
i have no idea why this problem even occurred!
Solved my problem at Magento 2.1.6 – varnish – nginx – redis & ubuntu 16.04 LTS! The error was happening only when at the front end i was trying to show all the products form a specific category, with the magento_URL+ ?product_list_limit=all while quantity of all these products were more than 128.
Thanks for this fix!!
I solved the issue by implementing Varnish caching. It hugely reduced loads and overcame the bottlenecks I was experiencing.
i’m getting 502 Bad Gateway nginx/1.10.3 (Ubuntu)please give some solution for that
I’m having the problem where I get 502 Bad Gateway – nginx/1.15.6.
I’m using Windows 10. I have no problem using Google Chrome. Internet Explorer 11 has the following issue:
When I first open the page I get the “502 Bad Gateway” error, however; if I reload the page with CTRL+F5 it loads fine. If I reload the page with just F5 I get the same error again. I can continue going back and forth with CTRL+F5 and F5 and it keeps going back and forth from working to “502 Bad Gateway” to working to “502 Bad Gateway”…
I fixed my issue with the “502 Bad Gateway” error:
1. I logged into “homestead ssh” and changed to myself to the root user “sudo -s”.
2. I modified the file: /etc/nginx/sites-enabled/homestead.test (my first Laravel web page) by changing the line that read:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
to read:
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
(My version of php is 7.2 not 7.0)
3. Ran: sudo service nginx restart
4. Ran: sudo service php7.2-fpm restart
Fixed !!!
Man! You saved my bacon, thx!
Thanks. It solved my problem.
Thanks, full. It solved my problem.
I’m solved my problem thanks.