502 Bad Gateway, nginx/0.7.67 as response to my website

Dear all, (copy from another forum, quote Tim's comment partially).

I am running a site through Linode Server. The recent maintenance change caused an error in some setting I cannot understand. The Linode Management panel says that everything is running, but when I look at the site and try to access it I get the following error

502 Bad Gateway

nginx/0.7.67

I have no clue what it is and Linode support basically say they do not understand it either and cannot help.

I have been working with the Putty thing and do get some access, but from there ( the sites prompt $) I do not understand how to move further.

Further, the site is running, but I would like to get all the files, and see how new developments can be carried out on it. The site is created in Python and Django.

Anyone with expertise on that?

Tim advised": "to configere the web application to start automatically at boot. It sounds like my web server, Nginx, is unable to communicate with the backend web application."

However, I have no clue what that is, how to get access and what the variables are for setting this to auto boot once Linode server is rebooted.

:?

William Goossen

3 Replies

Dear Michal,

Your instructions helped me to dig deeper into the server itself, I used additional guidance on basic unix commands to move between directories and list the files.

Apparently the sudo command you suggested to restart nginx did work for the restart, but the website is still showing the same message. Also a sudo reboot command did let the application server reboot, but still no success in accessing the website.

Perhaps I need to do more, but then the link you provided is showing too many options I guess. And the gunicorn is also completely new and has not been in place before. So I am not sure I need it at all. So any further help would be appreciated very much.

In particular, how can I find and restart the application server? :?:

In the meanwhile, with other commands to read the log file, I could detect one error in the nginx error log file:

2013/08/13 21:16:40 [error] 1676#0: *1 connect() failed (111: Connection refused ) while connecting to upstream, client: 86.81.201.17, server: r4c.clinicaltemplates.org, request: "GET /accounts/login/?next=/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:8082", host: "r4c.clinicaltemplates.org"

Perhaps this points to the next step? But again, I do not know where to go.

William

Your Django application needs to be run by an application server. This could be Apache with modwsgi, or gunicorn, or the uWSGI nginx module. The last two (gunicorn and uWSGI) need nginx to handle the incoming browser requests. Apache + modwsgi don't require nginx but they still run better with it anyway.

When nginx receives a request from a browser it passes that request to your application server. If it can't reach the application server then it returns the 502 Bad Gateway error to the browser.

So, in a nutshell, you appear to have nginx started but no application server.

To make things easy for now you should just run nginx with gunicorn as your app server. Some decent instructions for setting this up can be found at http://michal.karzynski.pl/blog/2013/06 … upervisor/">http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/

Hi all,

I got it solved and the site is running again as ever before. The issue was that I typed in nginx restart, which should have been nginx start…. Oh well, I learned a lot.

Thanks for your help, which made me confident to explore some options!

William

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct