176π
You can run it for machines in your network by
./manage.py runserver 0.0.0.0:8000
And than you will be able to reach you server from any machine in your network.
Just type on other machine in browser http://192.168.0.1:8000
where 192.168.0.1
is IP of you serverβ¦ and it ready to goβ¦.
or in you case:
- On machine
A
in command line./manage.py runserver 0.0.0.0:8000
- Than try in machine
B
in browser typehttp://A:8000
- Make a sip of beer.
24π
You need to tell manage.py the local ip address and the port to bind to. Something like python manage.py runserver 192.168.23.12:8000
. Then use that same ip and port from the other machine. You can read more about it here in the documentation.
- [Django]-Separating form input and model validation in Django?
- [Django]-How to merge consecutive database migrations in django 1.9+?
- [Django]-Django/DRF β 405 Method not allowed on DELETE operation
6π
I was struggling with the same problem and found one solution. I guess it can help you. when you run python manage.py runserver, it will take 127.0.0.1 as default ip address and 8000. 127.0.0.0 is the same as localhost which can be accessed locally. to access it from cross origin you need to run it on your system ip or 0.0.0.0. 0.0.0.0 can be accessed from any origin in the network.
for port number, you need to set inbound and outbound policy of your system if you want to use your own port number not the default one.
To do this you need to run server with command python manage.py runserver 0.0.0.0:<your port>
as mentioned above
or, set a default ip and port in your python environment. For this see my answer on
django change default runserver port
Enjoy coding β¦..
- [Django]-Django Rest Framework: Dynamically return subset of fields
- [Django]-Python Socket.IO client for sending broadcast messages to TornadIO2 server
- [Django]-Fastest way to get the first object from a queryset in django?
4π
Just in case any Windows users are having trouble, I thought Iβd add my own experience. When running python manage.py runserver 0.0.0.0:8000
, I could view urls using localhost:8000
, but not my ip address 192.168.1.3:8000
.
I ended up disabling ipv6 on my wireless adapter, and running ipconfig /renew
. After this everything worked as expected.
- [Django]-How to use permission_required decorators on django class-based views
- [Django]-How to delete project in django
- [Django]-How can I get the full/absolute URL (with domain) in Django?
3π
in flask using flask.ext.script, you can do it like this:
python manage.py runserver -h 127.0.0.1 -p 8000
- [Django]-Django Server Error: port is already in use
- [Django]-Django β How to set default value for DecimalField in django 1.3?
- [Django]-Django: how save bytes object to models.FileField?
2π
For people who are using CentOS7, In order to allow access to port 8000, you need to modify firewall rules in a new SSH connection:
sudo firewall-cmd --zone=public --permanent --add-port=8000/tcp
sudo firewall-cmd --reload
- [Django]-Django "xxxxxx Object" display customization in admin action sidebar
- [Django]-Django β No module named _sqlite3
- [Django]-Django error: got multiple values for keyword argument
1π
I had the same problem and here was my way to solve it:
First, You must know your IP address.
On my Windows PC, in the cmd windows i run ipconfig and select my IP V4 address. In my case 192.168.0.13
Second as mention above: runserver 192.168.0.13:8000
It worked for me.
The error i did to get the message was the use of the gateway address not my PC address.
- [Django]-ImportError: No module named 'django.core.urlresolvers'
- [Django]-How to access the local Django webserver from outside world
- [Django]-Django template tag to truncate text
1π
First, change your directory:
cd your_project name
Then run:
python manage.py runserver
- [Django]-How to get GET request values in Django?
- [Django]-How to configure where to redirect after a log out in Django?
- [Django]-Reload django object from database
0π
Ok just came across this post this is a little off topic but hopefully explains a few things, The IP 127.0.0.1 points to your network card so any traffic that you cause to go to that IP address will not leave your computer.
For example modern network cards in laptops for example will not even give you that IP if you are not connected to a wifi or cabled network so youβll need to be connected at least to activate the card.
If you need to run multiple servers on the same machine but want to access them with a domain then you have a couple of options
- edit your computers host file to define the domain and what IP it goes to
- use a DNS Alias I set up using a cname record years ago *.local.irishado.com will point to 127.0.0.1
so for example these three domains will point to your local machine
will all point to your local machine then in python projects you will need to edit the projects setting file ALLOWED_HOSTS property to hold the domain it will accept
ALLOWED_HOSTS = [βsite1.local.irishado.comβ]
- [Django]-Django Sitemaps and "normal" views
- [Django]-Django filter queryset __in for *every* item in list
- [Django]-What is the use of PYTHONUNBUFFERED in docker file?