I'm starting the tango-with-django tutorial.
And I'm trying to access the created website using other computer. Both computers are using Windows OS. And this is not working.
$ python manage.py runserver <your_machines_ip_address>:5555
I'm using the IPv4 Adress that I get when I type:
$ ipconfig
What am I doing wrong or what is missing?
Download ngrok from here: https://ngrok.com/ (this will allow you to serve your web app to anyone on the Internet)
Start your Django project normally or provide any port number.
python manage.py runserver
If you are running windows, open a command prompt and browse to the location where the ngrok binary is located.
If you are running GNU/Linux / OSX, just open a terminal.
Then run the following command.
ngrok 8000
Replace 8000 by whichever port the Django project is running on.
ngrok will give you a public hostname like http://abc.ngrok.com
Anyone you give this address to will be able to view / interact with your Django application anywhere on the Internet.
Update: Newer versions of ngrok need to be run like this: ngrok http 8000
Try python manage.py runserver 0.0.0.0:5555. And access it on the other machine using http://<your-ip-address>:5555. That should work
Related
In the cmd , after receiving my Ipv4 address using ipconfig , I have added it to the ALLOWED_HOSTS in the settings.py file .
Then to run the website , in cmd I ran the following command :
python manage.py runserver 192.168.x.x:8000 where 192.168.x.x is my ipaddress .
I am able to to access my website from my own local machine , however on other local machines : 192.168.x.x:8000/ isn't responding.
I fear, there is rather a fundamental misunderstanding of a local webserver. The webserver created when you run python manage.py runserver is just a programme running on your computer. You can make requests against that server in your browser using the address manage.py gives you, but that does not mean that the web server was on the internet.
What you expect is like having a Python script hello_world.py on your machine and expecting that someone else could just run python hello_world.py on their machine and it would invoke the script on your machine.
If you want to publish your website, you need to host it on a website.
Aemie,
Try hosting the django server on 0.0.0.0:8000 and attempt to access it from the different machine via the address 192.168.x.x:8000 (the ip address of the host machine IP).
0.0.0.0 would allow all IPv4 addresses on the local machine to be accessible
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
I am able to run my django dev server on my machine and make it accessible to the local network by running:
sudo python manage.py runserver IP:80
OR
sudo python manage.py runserver 0.0.0.0:8000
Now, how can I make my server accessible over the internet by a machine not in my local wifi network?
Use your machine LAN/WAN ip address, then configure your modem/router to let this ip have external access.
For example, considering your machine LAN/WAN ip address is 192.168.0.100.
You run your django development server as python manage.py runserver 192.168.0.100:8000.
An then, set up your modem/router.. Probably inside your DMZ settings.
You can use a tool like ngrok.
Here you can find a detailed usage description: http://www.lexev.org/en/2014/remote-url-localhost-server/
I'm working with PyCharm and I wonder if there's a way to make the Django embedded server accesible for the other hosts in my local network or I need to deploy my app on a dedicated web server such as Apache?
Now, I'm accessing my Django app like this in the browser:
http://localhost:8000/mypage/
and I want other users inside my local network to type:
http://my_private_ip:8000/mypage/
in their browsers and see the same page.
Just run the server (which is Django's embedded server FWIW, not PyCharm's) under http://my_private_ip:8000:
# ./manage.py help runserver
Usage: manage.py runserver [options] [optional port number, or ipaddr:port]
Starts a lightweight Web server for development.
(...)
# ./manage.py runserver my_private_ip:8000
Assuming a Unix environment.
You need to ensure the server is listening not on the lo interface but on all interfaces (or at least the one used to connect to the LAN).
If you can customize the way PyCharm launches the server, use 0.0.0.0 as the host, as in:
python manage.py runserver 0.0.0.0:8000
Your coworkers can then use your LAN IP address. If you don't know it, use $ ip a.
I really try not to ask questions on here, but I've been googling for a bit now and can't find the answer or another method to try. I have a CentOS box at my house hooked to a router. I've assigned it a static IP of 192.168.1.140. Because I'm lazy, I just ssh into it. When I'm goofing around with Django (learning Django/Python at the moment) and I run python manage.py runserver with a variety of IP address, I can't get my browser to access that box. I've tried
python manage.py runserver 0.0.0.0:8000
python manage.py runserver 8000
python manage.py runserver localhost:8000
python manage.py runserver 192.168.1.140:8000
python manage.py runserver 192.168.1.255:8000
python manage.py runserver 192.168.1.0:8000
python manage.py runserver 192.168.1.1:8000 #this errors out and says I can't use this IP address although this is the IP I use to access the router
When I run netstat -tln in another terminal I can indeed verify that it's listening on port 8000 to the specified address. In iptables I've run it just how it is and I've run it through tcp --dport 8000 and --sport 8000 with the same results. Just can't quite seem to crack the code. I've also setup port forwarding on my router so port 8000 is directed at 140. Is there a log somewhere I can check that I can't find on google? What am I missing?
Whilst googling I came close to an answer but I think it must be something else.
I'm running Python 2.7.5 and Django 1.5.2 through virtualenv if you need to know. Is virtualenv my issue? Thanks y'all
According to this documentation,
the right approach would be to set the python manage.py runserver xxx.xxx.xxx.xxx:yyyy to the IP address of the port you're using [Wi-Fi or Ethernet].
If the other devices are connected to the same LAN, then they should be able to access your Python VirtualEnv straight from their browsers.
Worked just fine on mine.
Also, I use DHCP - don't know if it changes anything. Just thought I'd mention that.