I am using Pycharm and testing on local dev server. All goes well until I try to connect to the local dev server from another laptop (windows).
My dev server is 127.0.0.1:8000 on a mac. On the second computer, I am able to ping the server's LAN ip 10.0.2.2 successfully. But enter 10.0.2.2:8000 in browser address bar doesn't connect to anything.
telnet 10.0.2.2 8000 in command line also fails.
How can I do this?
Listen to address 0.0.0.0 instead of 127.0.0.1
This means it will listen to all, you can listen to specific IP but this would work on both local and network.
For beginner like me, screenshot can help.
If leaving Host field to be empty, it will default to 127.0.0.1, which is not we want in such situation.
Related
I run my django website with python manage.py runserver 0.0.0.0:8080 on Vagrant which is set up to forward 8080 port to 8081 on host machine. I'm able to access this website on host by going to it's local ip (192.168.X.X) but can't on mobile device (of course also by going into it's local ip).
Any idea? All I could find about this is to run server with 0.0.0.0 what is already happening in my case.
Never mind, I've forgot to enable public_network in my Vagrantfile.
I am having problem accessing polymer serve from WLAN via local IPv4 address on port 8080 on Windows 10.
I have open up the port 8080 on Windows Firewall for TCP, but it doesn't resolve the problem.
I can access 127.0.0.1:8080 on local machine, but fail to access 192.168.0.x (i.e. local IPv4 address) from the same local machine on my web browser. Any idea?
use polymer serve -H 0.0.0.0
polymer serve defaults to localhost which typically is 127.0.0.1 only.
I have a Django web server on a VirtualBox/Vagrant machine running Ubuntu.
I have followed this guide to create a Django project: https://docs.djangoproject.com/en/dev/intro/tutorial01/
I have a web server running at http://127.0.0.1:8000/ inside my guest machine. This is the first time I am running a Django web server. It is supposed to be a hello world app.
How can I access this web application from my host browser?
I have tried running ifconfig in the guest to get the IP that I should visit I found a promising IP address in inet addr.
But I have tried entering the following into my host browser and it didn't work.
http://inetaddrnumbers:8000/
How can I access the web server from my browser?
Try this.
Open the vagrant file (should be in the directory where you specified to create a new vagrant machine).
Search for config.vm.network. If you didn't setup the file earlier, it should be commented.
Change it to look something like this config.vm.network "private_network", ip: "55.55.55.5". Here ip address (55.55.55.5) can be any ip address you want.
Now logout from the vagrant machine and reload your vagrant machine by this command vagrant reload.
Again ssh to your vagrant machine and restart your django server by this command python manage.py runserver 0.0.0.0:80. Again the port address (80) can be 8000 if you want so.
After that, in your browser, enter the following address 55.55.55.5, and hopefully you should see your webapp.
Now if you would like to go further, you can edit your host file, and add this line
55.55.55.5 mynewdomain.com
Then in your browser, enter the follow address,
mynewdomain.com
And you should see your web app. Note that, www is not added in the domain name inside the host file, so only mynewdomain.com can be accessed. You can however add it.
Hope this helps. Cheers.
Complementing #Kakar answer, this configuration can also be done using this:
config.vm.network "private_network", type: "dhcp"
This will assign an IP automatically.
For further reading: https://www.vagrantup.com/docs/networking/private_network.html
I'm running OS X Mountain Lion on a machine with local IP address 192.168.1.6 (as reported by both the Network utility and ifconfig) and am running a local (Django) development web server on port 8000 that I would like to connect to from a virtual machine running a guest OS on the same machine.
On the host OS (ie, OS X running on the metal of the machine w/ address 192.168.1.6) I can connect to my test web server through the browser by navigating to 127.0.0.1:8000; or localhost:8000; but not when using the machine's local IP address. Here's what makes this extra confusing:
The router is not filtering the ports; and, just to be sure, I've set it to explicitly forward ports 8000 and 22 to 192.168.1.6; And speaking of port 22,
When I start the SSH service, I can connect (from the command line) via ssh 192.168.1.6
It's not a browser issue, because I also can't telnet to 192.168.1.6 port 8000 (connection refused) while I can telnet to 127.0.0.1 port 8000, and I can also telnet to 192.168.1.6 port 22
The firewall is set to off (as reported in System Preferences) but to be extra safe, I've also set an ipfw rule to allow everything through
Here are the ipfw rules:
00100 allow tcp from any to any dst-port 8000
65535 allow ip from any to any
Here is additional confirmation that the port is, indeed, being listened to by my test server:
netstat -an | grep 8000
tcp4 0 0 127.0.0.1.8000 *.* LISTEN
so what's going on here? Somehow port 22 is being treated differently than port 8000, but every place I can think to look for those differences I can't find any. Why can't I get into this machine's port 8000 using its local ip address?
When you start Django development server you need to give the address explicitly:
python manage.py runserver 192.168.1.6:8000
Or if you want the server to run on all interfaces you can use:
python manage.py runserver 0.0.0.0:8000
In other case Django development server defaults to running on the local interface only.
The problem for me was I accidentally quit the server whenever trying to copy the server address. So instead of using ctrl+C just write down the address into your browser.
I solved the issue.There are a few things you might be missing.Listing them below-
1.Once it starts the server, do not press Ctrl+C anyhow .u might be pressing it to copy to url and that accidently closes the server due to which it might be happening.
2.instead of http://127.0.0.1:8000/ ...change the port number to http://127.0.0.1:8080/ ...That would work.
3.Try changing the firewall setting and allow the app.
4.Try opening it with different browsers and incognito too.
The above steps helped solve my issue.Hope they help u too...:)
We've got a server over which we're running a Django powered site. Since we want to test the site, we're using Django's build-in development server (i.e runserver). But I'm curious about the ip of the following command:
python manage.py runserver 0.0.0.0:80
It results in a running site we can visit using server's ip remotely.
But when using 127.0.0.1 instead:
python manage.py runserver 127.0.0.1:80
No one can visit the site with the sever's ip from another pc.
So why? What does 0.0.0.0 exactly means (Google says it's the default route) ? Why can't 127.0.0.1:80 be accessed remotely?
0.0.0.0:80 is a shortcut meaning "bind to all IP addresses this computer supports". 127.0.0.1:80 makes it bind only to the "lo" or "loopback" interface. If you have just one NIC with just one IP address, you could bind to it explicitly with, say, 192.168.1.1:80 (if 192.168.1.1 was your IP address), or you could list all the IPs your computer responds to, but 0.0.0.0:80 is a shortcut for that.
127.0.0.1 is the loopback interface, also known as localhost; this is an address that is only accessible from the same computer, as nothing actually goes over the network. 0.0.0.0 means "listen on all interfaces", and thus will listen for connections on all IP addresses that machine has (likely only one).
127.0.0.1 is the local (loopback) ip, not the ip of that computer on the network. To access a server across the network, you'll need to know its' network ip