Visit webpage hosted on ubuntu server in a local network - django

I have a ubuntu server hosting a web page driven by Python Django, I can access that page by using the following command:elinks http:// 127.0.0.1:8000.
Now if I want to access that same web page on a macbook sharing the same home router with my ubuntu server(local ip: 10.0.0.9), how would I do it? Typing in elinks http:// 10.0.0.9:8000 wouldn't work.
Thanks a lot,
ZZ

Are you running the development server using manage.py?
If so, you should start the server using:
python manage.py runserver 0.0.0.0:8000
This will allow the development server to be visited by ips on all interfaces instead of just localhost.

You need to serve it. There are a number of ways to do this, but my preferred method is to use Nginx as a reverse proxy server for gunicorn. This is a good tutorial for that.

Related

Axios with django server on localhost

Trying to access django server on localhost from my react native app. All I get is Network Error, which doesn't say much. Tried changing info.plist file as suggested in other answers on stack, tried changing firewall settings and so on.
The thing that worked and solved all my problems was changing the url on axios to my local ip and running django server with command: python manage.py runserver 0.0.0.0 which to my understanding will accept any connection to the server.

Installed "Python-django" on my Virtualbox but not able to access the web pages from host machine web browser

I am pretty new to Web-Development
I have Python-Django and apache2 installed on VirtualBox.The VirtualBox adapter settings are OK since i am able to visit the web pages hoisted from apache2.
Now the problem is when i tried to visit the pages hoisted by django inbuilt web-server
It didn't opened.
For apache2 port number is 80 and for django port number is 8000
Please help me to get through this problem
Django development web server normally binds to localhost (127.0.0.1) only, therefore you can only access it from the same machine (or VM). You can change this behavior by starting it using:
python manage.py runserver 0.0.0.0:8000
This way it will bind to every IP address (both 127.0.0.1 and whatever IP address you gave to your VM) so that you can access it from "outside".

How to view the webpage in Django tutorial on Linode server

I know I have similar question with this post: Django tutorial on remote server: how to view in my browser? But I just can't solve it with the answer it has.
I am playing with Django framework now. I am trying to do the Django tutorial on my Linode server. Everything works fine, but when we have to examine the webpage we have, the tutorial says that we have to check http://127.0.0.1:8000/ on the server. I only have command line access on the Linode server, so I don't know how to see that webpage on the linode from my desktop. I tried to use the command like python manage.py runserver 123.123.123.123:8000 and set the ip to my Linode server, but I still can't access that webpage from my desktop (I do remove the firewall for 8000 port). Does anyone know how can I check the change for the remote webpage I created within Django framework on the Linode server? Thanks.
Just to make sure, are you trying to access the following URL in your browser (where the server ip address is 123.123.123.123)?
http://123.123.123.123:8000
Secondly, are you able to telnet to port 8000, to make sure you have correctly opened the port on the firewall.
I had this problem too and I wanted to clarify what I did for others who might get stuck:
First, remove the firewall for port 8000
sudo nano /etc/iptables.firewall.rules
-A INPUT -p tcp --dport 8000 -j ACCEPT
Second, reboot the linode
Third, restart the development server
cd /home/mycode/mysite
python manage.py runserver 123.123.123.123:8000
(where you use your ip)

Django on SSH public IP

I have Django installed on my SSH-server. But the SSH-server I'm working on, is not at my home. So the local ip-adres Django creates (127.0.0.0:8000) isn't available for me, I can't test my Django-apps graphicly.
What could be a Solution to get it work?
Djano has a command runserver that could set the IP-adres of the server like this:
django-admin.py runserver [IP]:[port]
But which IP I have to fill in there to make it work? The only IP I have is the IP of the SSH-server. Isn't it possible to fill in the IP-address of my webhost(but where I need to give in password etc)?
Thanks a lot!
Choose a publicly available port (say 8000), or redirect an existing web server to use the port you choose, and then start with
django-admin.py runserver 0.0.0.0:8000
Edit
If you happen not to control your available ports, you probably need to hook apache in front of your app. See https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/ for info on how to deliver your app with apache and mod_wsgi.
You can try Putty with its tunnels. This program for windows, but I think you can find it for Linux if you use it. I used it to get access to my Postgres databse with pgAdmin with this article. So you can use tunnel for 8000 port and program to get access to it on your local machine.

Django & Apache: How to debug on Testing server

I am trying to debug an issue that happens on our testing server. So how do I make it so that I can access our testing server when I start Django by typing:
python manage.py runserver
?
Does it have to pass through Apache? If so, I need to configure Apache somehow but I am not using mod_wsgi and so, don't know how to do this.
Thanks! :)
the test server runs its own web server. the defaul options starts a server on
http://127.0.0.1:8000/, which you can then open in your browser
you can specify an optional ip address/server using
manage.py runserver ip:port
using ip 0.0.0.0 for all network interfaces