cannot acces http://server_domain_or_IP:8000 - django

I am using an AzureVM to host my development API server written in django.
There, I cloned my codebase and did all the requirements.txt installation. Before executing the manage.py runserver 0.0.0.0:8000 command, I changed the firewall permission rule: sudo ufw allow 8000.
The sudo ufw status commads shows the following result:
Status: active
To Action From
-- ------ ----
Nginx HTTP ALLOW Anywhere
8000 ALLOW Anywhere
OpenSSH ALLOW Anywhere
Nginx HTTP (v6) ALLOW Anywhere (v6)
8000 (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
and then I run python3 manage.py runserver 0.0.0.0:8000.
I should be able to see the default django page # http://SERVER_IP_OR_DOMAIN:8000
But nothing shows.
whereas if I hit http://SERVER_IP_OR_DOMAIN, I can see the NGINX landing page.
I am following this blog from digital ocean.
Here is my VM network rules:
How can I fix this?

I tried to reproduce the same in my environment and got the results like below:
To resolve this issue:
In your virtual machine make sure to Add inbound port Destination port ranges as 8000 like below:

Related

how to run apache superset in dev mode on aws ec2

I have developed a plugin for the apache superset,for which I have followed the following tutorial https://preset.io/blog/2020-07-02-hello-world/
In this tutorial the setup only works for development environment. So I need to run the backend server and frontend server separately using these commands.
for backend:
superset run -p 8088 -h 0.0.0.0 --with-threads --reload --debugger
for frontend:
npm run dev-server
In inboud rules in the security group for my EC2 instance, I have set the inbound rules to custom tcp where I have allowed the traffic for port 9000, 8088.
however I am unable to ping publicDNS of EC2:9000
this is not the case when I ping publicDNS of EC2:8088
turns out if we edit the webpack.config.js file and add an additional parameter for for host by passing devserverHost = '0.0.0.0' and then replacing the 'localhost' with ${devserverHost} solves the problem, additionally this also has to be done for the webpack.proxy.config.js file

Amazon Lightsail VPS not working with Nginx? (Django React project deployment)

I've newly registered with Amazon VPS service, Amazon Lightsail. After properly setup my Django app, Gunicorn and Nginx, it seems that there's some problem with the traffic?
I set up the same Django app on two different VPS using the same process, both with Ubuntu 18.
The IP isn't working on AWS (13.124.94.92):
~# ping -c3 13.124.94.92
PING 13.124.94.92 (13.124.94.92) 56(84) bytes of data.
--- 13.124.94.92 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2044ms
The IP is working perfectly (5.63.152.4) in another VPS Ubuntu 18:
~# ping -c3 5.63.152.4
PING 5.63.152.4 (5.63.152.4) 56(84) bytes of data.
64 bytes from 5.63.152.4: icmp_seq=1 ttl=64 time=0.063 ms
64 bytes from 5.63.152.4: icmp_seq=2 ttl=64 time=0.108 ms
64 bytes from 5.63.152.4: icmp_seq=3 ttl=64 time=0.082 ms
--- 5.63.152.4 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2043ms
rtt min/avg/max/mdev = 0.063/0.084/0.108/0.019 ms
The first IP isn't showing 'Welcome to Nginx' page while the second does (http://5.63.152.4/)
I'm not sure where to start to debug this... I've fiddled with iptables a bit, for failing to have mosh working. Please help! Thanks!!!
Additional Info:
Firewall active
~$ sudo ufw status
Status: active
To Action From
-- ------ ----
60000:61000/udp ALLOW Anywhere
Nginx Full ALLOW Anywhere
OpenSSH ALLOW Anywhere
mosh ALLOW Anywhere
5432/tcp ALLOW Anywhere
60000:61000/udp (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
mosh (v6) ALLOW Anywhere (v6)
5432/tcp (v6) ALLOW Anywhere (v6)
nginx status
~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
/etc/nginx/{sites-available, sites-enabled}/myproject
server {
listen 80;
server_name server_domain_or_IP;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/sammy/myprojectdir;
}
location /media/ {
root /home/sammy/myprojectdir;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
gunicorn status
~$ sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; disabled; vendor preset: enabled)
Active: active (running) since Fri 2020-05-01 06:14:48 UTC; 1h 17min ago
Main PID: 14512 (gunicorn)
Tasks: 4 (limit: 517)
CGroup: /system.slice/gunicorn.service
...
For other newbie like me:
Problem solved... Amazon Lightsail has its own firewall under 'Networking' tag on the control panel. So no need to set ufw yourself in Ubuntu. The welcome page of Nginx simply does not show. Once you are done pointing your domain to the public IP of the Lightsail instance, you are all set.
My particular problem was, Django require SSL access because of the settings I made. Hence, after SSL is installed using cerbot the website is accessible.
PS. It's a good idea to disable the 8000 port before finishing off your deployment.

Django Application running on Ubuntu VPS: This site can’t be reached

I am running an ubuntu 16.04 cloud VPS server. I've set up a venv and activated it, and installed django.
I run the server with
python3 manage.py runserver 0.0.0.0:8000
I am trying to access this application from a remote computer (not inside the same LAN); I'm trying to make the application visible to the world outside the VPS and VPLAN. When I try to access the site in my home computer broswer like: xx.xx.xxx.xxx:8000 I get the error:
This site can’t be reached. http://xx.xx.xxx.xxx:8000/ is unreachable.
Now I've tried a traceroute and it seems to reach the server ok. I also did
sudo ufw enable
sudo ufw 8000 allow
sudo iptables -S | grep 8000 (and see the proper entries)
In the settings file I have:
ALLOWED_HOSTS = ["*", "0.0.0.0", "localhost", "xx.xx.xxx.xxx","xxx.temporary.link"]
If I wget localhost:8000 I get a response fine. I have tried doing all of the above as root and as another dedicated user but it makes no difference.
I ran through this guide
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
and I still have the same issue.
Does anyone have any other ideas? Thanks in advance
Try:
sudo ufw allow 8000
Not:
sudo ufw 8000 allow

app running on django dev server inaccessible from network computer

How do I access an app running on django dev server(ubuntu 15.10) from another machine on the same network(eg. a windows 7) ?
I am able to ping this machine from another network computer.
"python manage.py runserver 0.0.0.0:8000" - does not allow me to access the app from another network computer.
app uses django 1.5.9
https://docs.djangoproject.com/en/1.8/ref/django-admin/#django-admin-runserver
Note that the default IP address, 127.0.0.1, is not accessible from
other machines on your network. To make your development server
viewable to other machines on the network, use its own IP address
(e.g. 192.168.2.1) or 0.0.0.0 or :: (with IPv6 enabled).
runserver 0.0.0.0:8000
Make sure you open port 8000
python manage.py runserver 0.0.0.0:8000
is ok but you have to also modify settings.py of your app. You need to change ALLOWED_HOSTS.
For example put * to allow access for everybody or put only certain IPs to limit access:
ALLOWED_HOSTS = ['*']
more answers here:
CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False

Allowing external access through firewall to Django in Windows

I want to allow external access to my website, which is being hosted by Django (development server) on Windows 7. To run the server on port 8000, I enter:
python manage.py runserver 0.0.0.0:8000
If I disable the Windows firewall, then this can be accessed externally. However, enabling the firewall means that it cannot be accessed externally.
So, I tried adding an "Inbound Rule" at "Control Panel\System and Security\Windows Firewall\Advanced Settings". Here, I allowed inbound TCP access via port 8000.
However, my website still cannot be accessed externally. What else do I need to do?
Environment Version
OS:Windows 10
Python:3.9.13
Django:4.0.1
open cmd.exe,then run:
netsh advfirewall firewall add rule name="Django Web Server" protocol=TCP dir=in localport=8000 action=allow
If your public ip address is 1.1.1.1
settings.py
# load production server from .env
ALLOWED_HOSTS = ['localhost', 'localhost:5085', env('SERVER', default='127.0.0.1'),'1.1.1.1']
open cmd.exe,then run the server on port 8000:
python manage.py runserver 0.0.0.0:8000