Can't get basic Django setup working on VPS - python

I'm trying to deploy a Django website on a VPS (CentOS) and I'm running into problem right from start. Here is what I've done:
ssh root#myserver.com
cd /home/mydomain/public_html
pip install django
django-admin.py startproject mysite
cd mysite
python manage.py runserver 0.0.0.0:8000
When I visit mydomain.com:8000 I expect to see the initial Django page "It worked!". But instead the browser just hangs and the connection times out.
Is there something I'm missing here?

If you cannot reach the site try the following:
$ wget http://127.0.0.1:8000
If you get a response locally but not through the network it could be a firewall or iptables issue. CentOS comes fairly locked down so check the ip tables.
http://wiki.centos.org/HowTos/Network/IPTables#head-cdc2ff6985016368c04d0b37a5914eef2e8d5796

Related

python manage.py runserver not working on on localhost:8000

I am new to django and trying to run the django server for the first time. I am trying to run the command for starting a django server in a terminal, i.e. python manage.py runserver. But when I go to http://localhost:8000, it is not giving me the default django output containing a rocket like image.
I even tried using http://my_ip:8000 and http://127.0.0.1:8000 but still it doesn't work. I also tried running the command as python manage.py runserver 8000 but it still does not give me anything on localhost:8000.
I have checked and no firewall / antivirus is blocking this port for me. Also, I am able to access other applications on other ports.
I am not getting any errors on my terminal when I run this command. This is a blocker for me and any help would be really appreciated.
Follow the image of my vs code integrated terminal here
Find my image of browser navigated to http://localhost:8000 over here.
I am using the latest python version 3.9 and my django version is 3.2.
Thanks!

Can't access Django runserver from URL or IP on Ubuntu 18.04

I had a project that I transferred to Ubuntu with Git. Everything was working, then I updated some files and then it did not work. Being I am fairly new to this, I reinstalled the Ubuntu image on the server and tried again, still with no success.
I deleted my Django project rm -r my_project and created a brand new project on the server, both with Django 3.0.3 and with Django 2.2.9. Both have the same results. I loaded Nginx on the server and can get the default Nginx page from the URL and IP, but Django is nothing. Below are my settings. I tried with and without the firewall.
settings.py
# Tried this
ALLOWED_HOSTS = ['*']
# And this
ALLOWED_HOSTS = ['my_domain','my_IP','localhost']
And then ran this from the virtualenv
python3 manage.py runserver 0.0.0.0:8000
Which loaded normally and can be curled from inside the server, but
my_domain:8000 and my_ip:8000
never connect and times out. I know not to use the Django server, but I can't get anything to work (gunicorn or anything other than Nginx default page).
UPDATE
After going through this article, it works now. Although the steps that it has you check the runserver and gunicorn before connecting it to nginx did not work.

My Django server is not responding anything

Basically when I enter this command :-
$- python manage.py runserver
In command prompt it's shows my server address which is usually http://127.0.0.1:8000/
But when I enter this in Chrome it's doesn't showing me anything just showing "This site can't be reached"
Please help me out because I am new to Django..
I also typed the command like
$- python manage.py runserver 0.0.0.0.8000
And this
$- python manage.py runserver [::] :8000
But still I can't see Django "Rocket".. !!
And also I thing I want to tell that I am using WiFi for internet . So it's OK or else using Django server we need lan connection.
If you follow the steps in this tutorial you will be able to get your first app started.
Make sure you are in the directory where manage.py is located before you run python manage.py runserver
Django can be used with WiFi without any problems.

Django server is not working on Virtual Server

I have a server that is using Ubuntu. I have uploaded my Django project to the server. And ran the command:
python manage.py runserver 0.0.0.0:80
But when I try to go the website in browser I get The requested URL could not be retrieved error.
What can be the reason of that?
python manage.py runserver {YOUR_PUBLIC_IP}:80
Also you need to check firewall settings, make sure that 80 port is opened

python manage.py runserver not work

I am trying to learn django on my mac by following along with Writing your first Django app
I run
django-admin.py startproject mysite
and it creates the files it should. Then I try to start the server by running
python manage.py runserver 8080
It's OK,the message is :
Validating models...
0 errors found Django version 1.4.2, using settings 'mysite.settings'
Development server is running at http:// 127.0.0.1:8080/ Quit the
server with CONTROL-C.
But I when I visit the 127.0.0.1:8080, I get a 504 error page:
This Page Cannot Be Displayed
The system cannot communicate with the external server ( 127.0.0.1 ).
The Internet server may be busy, may be permanently down, or may be
unreachable because of network problems. ......
What am I missing here?
Considering you are using a proxy (as mentioned in the comments). The reason for this error:
This Page Cannot Be Displayed
The system cannot communicate with the external server ( 127.0.0.1 ). The Internet server may be busy, may be permanently down, or may be unreachable because of network problems. ......
is that 127.0.0.1 is looked up at the proxy and on the proxy server there is nothing listening on port 8080
Use 'python manage.py runserver 8000' instead of 'python manage.py runserver 8080'
Worked for me.

Categories