I have a python script that uses PySimpleGuiWeb. I want to host it on my server and connect to it from another computer. But the script is running on 127.0.0.1. Can I somehow change this, or is there another way?
From the host device running the pysimplegui python script, you can likely load the gui via 127.0.0.1:###### through a browser (where ##### is your port). This is because it's hosted and being accessed from the same device.
Accessing from another device on the same network: try using the IP of the device hosting the pysimplegui followed by the same port as is used locally by host device to access gui.
e.g. 172.20.10.5:######
IP of the host device found via:
Linux(terminal):
ifconfig
Mac(terminal):
ifconfig
Windows(command prompt):
ipconfig
You can make the IP of your gui host device static and according the pysimplegui you can make the port static too, therefore the GUI should be always found at the same IP:port externally (given the static IP holds and doesn't get reallocated and that port isn't blocked for any reason by network etc.)
Update:
In addition, with some further reading, optional arguments to a 'Window' include:
web_ip='0.0.0.0', web_port=0
https://github.com/PySimpleGUI/PySimpleGUI/blob/master/PySimpleGUIWeb/PySimpleGUIWeb.py
Related
I want to set up a Django development server that both my computers and smart phones can access whilst on my network via wifi.
I've already set up a development server that my computer can access on http://127.0.0.1:8000/. However, my other devices can't.
The Django documentation says:
"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 or :: (with IPv6 enabled)."
I've found my "public IP address" and tried to use this by:
python manage.py runserver xx.xx.xxx.x (where this is my public ip address) but i get a "Command error: 'xx.xx.xxx.x' is not a valid port number or address:port pair."
I then tried the same with :8000 after the IP address, but got an error "Error: That IP address can't be assigned to".
Then python manage.py runserver 0.0.0.0:8000. The command line reports "Starting development server at ...", but when i try "http://0.0.0.0:8000/" on Chrome, i get a "This site can't be reached error".
Is it something to do with my windows firewall settings?
Please can you someone help me? Thanks!
This is very late, but I run onto an additional issue following this post. If you are using a rhel distro based and if firewalld
is enabled it might be blocking the connection. So for testing purposes run:
systemctl stop firewalld
0.0.0.0 is not a real address, it's a placeholder that just says that the server is not bound to a specific IP.
If you run on 127.0.0.1, it will only answer to queries that where addressed to 127.0.0.1, so localhost only.
Using your private address (192.168.0.x most often), it will only answer to queries to this address (so opening with the 127.0.0.1 should not work, but sometime does depending on the implementation)
So, if you use 0.0.0.0, it will answer to anything.
tl;dr : use 0.0.0.0 and connect using :
127.0.0.1 from this computer
your computer's private ip address for other computers inside your lan
you public IP for computers outside your lan. Note that this will require additional configuration on your router
You will need your local ip address not public.
You can get the local ip in windows machine by typing the following command in cmd : ipconfig .
On Linux type the following in terminal : ifconfig
The ip address will be of the form 192.168.0.101[Example]
So in your phone's browser type : 192.168.0.101:8000
Lately I've been playing with Python to discover its potential and I've just stumbled upon SimpleHTTPServer.
I'm on Windows 10.
I run:
python -m SimpleHTTPServer
the output is:
Serving HTTP on 0.0.0.0 port 8000 ...
I've opened the browser both on smartphone and tablet, but none of them can connect to the server when I type "http://127.0.0.1:8000".
(Translating from italian, maybe is not the exact translation)
iPad: "Safari can't open the page because the server has stopped responding"
Android: "WebPage does not respond. the webpage may be temporarily not available or it could have been moved to another address"
Why does it not work? How do I fix this?
Maybe your firewall is blocking access to python based server
Try this:
Open windows firewall
click on "allow an app or feature..." on the left side of the opened window
search for python in the list and check both the boxes private and public
It should work now
127.0.0.1 is always the IP address of the local system (its associated hostname is "localhost"). In other words, if you type 127.0.0.1:8000 on your tablet or Android device, the browser on that device will try to connect to a server running on the same device, listening on port 8000. You'll need to find out the IP address of the computer you're running Python on, and type that instead. You can use the ifconfig command on Unix, or ipconfig on Windows.
I am SSHing to a server, where Flask is set up. When I execute the flask application, the terminal says Running on http://0.0.0.0:80/, as is written in the file.
Is there any way to view this site on my local machine? Going to the domain above on my local machine just gives a Site Not Found error.
Do I need to just change the IP, or is this not possible?
In the Internet Protocol Version 4, the address 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown or non-applicable target...
In the context of servers, 0.0.0.0 means "all IPv4 addresses on the local machine"
-- Wikipedia: 0.0.0.0
Key words being "on the local machine". Which means http://0.0.0.0:80/ is not the actual address of the server, just the address it is "listening on".
You need to use the public IP address of the server that you are accessing. If you SSH'd into this machine, you should be able to use the same IP address or hostname to access the now running webserver.
I'm trying to set up two servers on my laptop using the script in https://github.com/misheska/foundations-of-python-network-programming/blob/master/python2/02/udp_remote.py.
As far as I understand, I can set a server just by typing
$ python udp_remote.py server
I want to start another server using my external IP, that I get using:
$ wget -q -O - http://myexternalip.com/raw
XXX.XXX.XXX.XXX
Then the server should be set with
$ python udp_remote.py server XXX.XXX.XXX.XXX
right???
Your syntax is correct (other than your IP4s being only 3 bytes long), but there are a couple reasons why you're having trouble:
It's not possible to bind to the same port twice on the same interface. Because the script has a fixed port number, you won't be able to run more than one instance unless your laptop has multiple interfaces.
Your WAN IP address will only be resolvable to an interface if your laptop itself is actually assigned that address. If the laptop is connected to a router and is assigned a local address, you won't be able to use the WAN address to specify the interface.
You cannot bind to an IP address that is not bound to an interface on the computer. If you require port forwarding to be set up on a router then consult your network administrator.
I'm have an issue with running the built in Python server that comes with 3.1, this may or may not be an issue with Python, in fact it probably isn't.
I start my server in the correct directory with "python -m http.server 8000" as the documentation suggests (http://docs.python.org/release/3.1.3/library/http.server.html).
When I navigate to that port on my local network with another computer using the url 192.168.2.104:8000 (my local ip and the port) my page loads. When I use my global IP, however, it stops working. Port 8000 is forwarded correctly. I used www.yougetsignal.com to verify that port 8000 was open using my global IP. Why in the world would Chrome be saying "Oops! Google Chrome could not connect to [REDACTED]:8000" then? Other server applications (such as my Minecraft server) work just fine. Is there something I'm missing? Furthermore, why would yougetsignal connect to my port but not Chrome?
With most routers ports are only mapped when someone connects from the outside (internet/WAN). You're testing it from your LAN so basically you're connecting to your router when you use your public IP. Ask a friend to test, i.e. from an outside connection.