6đź‘Ť
192.168.*.*
is a LAN-private address — once you’ve done the proper VMWare (or other VM manager) and firewall incantations to make it accessible from the LAN, it still won’t be accessible from outside the LAN, i.e., from the internet at large (a good thing too, because such development servers are not designed for security and scalability).
To make some port of a machine with a LAN-private IP visible to the internet at large, you need a router with a “virtual servers” ability (many routers, even cheap ones, offer it, but it’s impossible to be specific about enabling it since each brand has its own idiosyncratic way). I would also recommend dyndns or other similar service to associate a stable DNS name to your always-varying public IP (unless you’re splurging for a static IP from your connectivity provider, of course, but the latter option is becoming costlier all the time).
superuser.com or serverfault.com may provide better answers and details (once you give every single little detail of your configuration in a question) since the question has nothing much to do with software development and everything to do with server administration and configuration.
98đź‘Ť
python manage.py runserver 0.0.0.0:8181
This will run development server that should listen on all IP’s on port 8181.
Note that as of Jun 17, 2011 Django development server is threaded by default (ticket #1609).
From docs:
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.
- [Django]-Django Order By Date, but have "None" at end?
- [Django]-Django query filter with variable column
- [Django]-Custom django admin templates not working
11đź‘Ť
Assuming you have ruby installed, you just have to get localtunnel:
gem install localtunnel
then start your python development server with:
python manage.py runserver 0.0.0.0:8000
in another shell, start localtunnel:
localtunnel -k ~/.ssh/id_rsa.pub 8000
That will output an url to access your local server.
Port 8000 is now publicly accessible from http://xxxx.localtunnel.com
That’s it.
- [Django]-Exclude a field from django rest framework serializer
- [Django]-Django: How to check if the user left all fields blank (or to initial values)?
- [Django]-Why don't my south migrations work?
7đź‘Ť
I had to add this line to settings.py in order to make it work (otherwise it shows an error when accessed from another computer)
ALLOWED_HOSTS = ['*']
then ran the server with:
python manage.py runserver 0.0.0.0:9595
Also, make sure that your firewall allows communication to the chosen port (9595 in this case)
- [Django]-How do I package a python application to make it pip-installable?
- [Django]-Django string to date format
- [Django]-Logging in Django and gunicorn
4đź‘Ť
Already answered but adding npm alternate of same localtunnel
sudo npm install -g localtunnel
lt --port 8000 --subdomain yash
- [Django]-Django vs. Model View Controller
- [Django]-How to delete old image when update ImageField?
- [Django]-How to use dynamic foreignkey in Django?
1đź‘Ť
If you are using Virtualbox, You need to change the network setting in VB from “NAT” to “Bridged Adaptor”. Then restart the linux. Now if you run sudo ifconfig
you are able to see your IP address like 192.168.*.*
. The last step is runserver
python manage.py runserver 192.168.*.*:8000
Cheers!
- [Django]-How to specify an IP address with Django test client?
- [Django]-How to reset migrations in Django 1.7
- [Django]-How to put timedelta in django model?
0đź‘Ť
You need to configure bridged networking in VMWare and also grant access to the target port in Ubuntu firewall.
- [Django]-How to update fields in a model without creating a new record in django?
- [Django]-How to perform filtering with a Django JSONField?
- [Django]-OneToOneField and Deleting
0đź‘Ť
Might I suggest trying something like pyngrok
to programmatically manage an ngrok
tunnel for you? Full disclosure, I am the developer of it. Django example here, but it’s as easy as installing pyngrok
:
pip install pyngrok
and using it:
from pyngrok import ngrok
# <NgrokTunnel: "http://<public_sub>.ngrok.io" -> "http://localhost:8000">
http_url = ngrok.connect(8000)
No messing with ports or firewalls or IP addresses, and now you can also inspect the traffic (which is useful since what you’re doing here is ongoing development, not running a prod
-ready server).
- [Django]-Django migrations – workflow with multiple dev branches
- [Django]-Difference between reverse() and reverse_lazy() in Django
- [Django]-Django error: got multiple values for keyword argument
0đź‘Ť
Alternatively, you can use cotunnel, Just run cotunnel in your ubuntu (in VMware) change your tunnel port in cotunnel dashboard which port you are using in local side. It gives public url and you can share the url with your friends.
Your Django server can listen to 127.0.0.1 or 0.0.0.0 (I prefer 0.0.0.0) it does not matter for cotunnel.
- [Django]-Django, filter by specified month and year in date range
- [Django]-Django "Remember Me" with built-in login view and authentication form
- [Django]-Django Rest Framework model serializer with out unique together validation