Search code examples
djangopython-2.7django-project-architect

Django - how to run it on a production server?


I am new to Django Project. I have my app moved to my production server and I have it run:

$ python manage.py runserver
>>> Starting gulp watch
>>> gulp watch gulp process on pid 30427
Validating models...

0 errors found
May 18, 2017 - 15:57:08
Django version 1.5.12, using settings 'website.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

But it is a production server with an IP, eg: 119.237.27.131

So it can't be running at http://127.0.0.1:8000/

Then what should I do so that the app is running on http://119.237.27.131:8000/ instead?

Any ideas?

Btw, where is 'website.settings'?

EDIT:

When I check the app at http://119.237.27.131:8000/

I get this error:

This site can’t be reached

119.237.27.131 refused to connect.


Solution

  • If you start the development server without any parameters, the server will start at localhost:8000, but it can't be accessed from outside the machine. To allow that, you should start the server like this:

    python manage.py runserver 0.0.0.0:8000
    

    That will allow you to connect from another machine, on the machine's IP address, like http://119.237.27.131:8000/

    A word of warning: the development server is not a production-ready server. You should use a WSGI server like Gunicorn or another tool to serve your application. Do not use the development server in a production setting, it's not safe!! Read more about that here.