Fixing 502 Bad Gateway Nginx
Вставка
- Опубліковано 10 вер 2024
- This video shows you how to fix the 502 Bad gateway and "connect() failed (111: Connection refused) while connecting to upstream" Nginx errors!
Useful links:
- Affiliate link for $100 free credit for DigitalOcean so you could spin up your own servers:
m.do.co/c/2a9b...
- How to Troubleshoot Common Nginx Issues on Linux Server:
www.digitaloce...
- More useful Nginx discussions:
www.digitaloce...
www.digitaloce...
- Twitter:
/ bobbyiliev_
If you have any questions feel free to reach out to me! 🙌
Best way to do that is to post a question on the DigitalOcean community forum here:
www.digitalocean.com/community/questions
I just have to say that this video is incredibly well done, very simple and yet well put steps for everything, to the point of feeling embarrassed after you watch, because those steps should really be simple and make sense right away. Thank you very much.
Thank you very much for your feedback! I am really happy to hear that this helped you!
Thank you so much! I followed your steps and it was indeed because I accidentally closed my node server. Now I feel stupid
No problem at all! Thank you for the nice feedback and happy to hear that this helped you!
Brilliant! This video helped me a lot. Thank you and keep it up👍
Thanks! Happy to hear that this was helpful! 🙌
Thank you so much Champ.
You have saved me a lot.
Great solution.
No problem at all! Happy to hear that this was helpful!
Very useful and meaningful content, THANKS!
Glad you liked it!
Hi,I got 502 bad gateway nginx error on browser after calling DRF api..can you plz tell me how to fix this
When i type docker ps -a the container is empty. What can i do about it?
saved my day thanks
Really happy to hear that!
i have same problem but u give solution for docker file , how i can solve it in ubuntu cli terminal
Very Useful. Thank you for the video.
Thanks a lot Bobby Iliev
You are welcome!
Hello bro. when I type sudo cat /etc/nginx/sites-enabled/default there is a error like this: cat: /etc/nginx/sites-enabled/default: No such file or directory . what is wrong? thank you very much.
Hi there 👋, what OS are you using? You can check the OS with this command:
cat /etc/os-release
@@bobbyiliev_ Linux / Ubuntu.
@@aslanhuseynov3481 Hello, it is possible that you have a different Nginx configuration file in there with another name. Use the ls command to check the files in there:
ls -l /etc/nginx/sites-enabled/
@@bobbyiliev_ Hello, yes i have a different nginx configuration file which I wanted to create a new project. but this file is not texted as you have. thank you for your answer. i will wait.
well that's great. but i can't connect to the nginx this way, it there a way to do that on aws console?
thanks for the video!! helped me a lot!!
Really happy to hear that it was helpful!
I create my Wordpress site before for scratch. And a few weeks ago. I put some DNS in my ethernet section. There is no problem with that or i need to change what DNS I put ? I put only 1.1.1.1 and 1.0.0.1 for internet download speed purpose.
And yesterday I see my Wordpress site exprncing 502 nginx error. Although my Wordpress version was old. I update it and all plugins. But instead I resolve my problem it's goes to Maintenance.
Hi there, the 502 error is not likely caused by the DNS change.
I would recommend checking if the PHP FPM service is up and running on the server. If not make sure to start it.
Hi please answer my question..
Iam struggling from last week's.
Iam using gke clustee, configured nginx ingress controller,
2 applications are deployed to gke container ports are for http: 8081, https: 8088, I have configured ingress rules but got 502 bad gate way.
How to troubleshoot this?? How to start the backend service
Helpme with this befor my manager fire me
Make sure to check your logs first to see the actual error. If the applications are deployed, make sure that the ports are actually exposed correctly and also make sure that the applications are running.
@@bobbyiliev_ I acn able to access the application with type load balancer. But iam unable to access to acces with ingress. I check the logs of ingress pod. It's showing the error as "http/1.1 connection refused while connecting to upstream"
Thank you. This was very helpful.
No problem! Happy to hear that it helped!
very helpful ty
No problem at all! Happy to hear that this helped!
hello, what would you do for node js backend server?
Hi there, you would need to make sure that the Node js service is up and running. If it is not running you would need to check the logs and see why it has crashed.
@@bobbyiliev_ I have posted the question in digital ocean. Waiting for your response :) www.digitalocean.com/community/questions/502-bad-gateaway-nginx
@@suneel1875 Hi there, just posted a reply 🙌
very helpfull
Glad to hear that!
Whaat is the equivalent cmd to docker ps -a for nodejs server
I just got error bad gateway omg how do u fix that
Best thing to do is to check your Nginx error log first to see the actual problem rather than the generic error:
tail -100 /var/log/nginx/error.log
Do i need to install docker 1st??
No, docker is just used as an example here. If you are running an app like Node.js or PHP FPM then you need to make sure that the application is started.
Hello Thanks for the great video!
}
location @puma {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_pass 127.0.0.1:5000;
}
Im getting a service that is running on port 5000. I checked online and found that it is FLASK service that use by default port 5000. Do you have any idea how to restore it?
Please notice that received this error on a SMTP server with postal application and nothing else installed.
Any ideas on what to do next ? Thank you
Hi there, as far as I can see form the config it looks like that the backend service is puma. It would depend on how puma is setup, but if there is a systemd service for it you could start it with: systemctl restart puma
How can i came to this page
Hi there, You would need to first SSH to the server.
I DONT HAVE A DOCKER ID. tf im supposed to do now
You need to start your backend service. In the video I mention that it is not necessarily docker. What is the proxy rule in your Nginx server block?
Not useful at all
Sorry to hear that, feel free to share more details about your problem and I will be happy to advise you further!
i have the same port in the container and nginx.conf so what to do ? its still show me bad getway
What do you see in your error logs?