Is there a way to generate a specific IP address or make a specific site of flask http://127.0.0.1:5000/ site which runs locally, to access the web-app made using flask from different device as by default it runs locally and under http://127.0.0.1:5000/ but,i want to access it from different devices.If,there's a way please help
Asked
Active
Viewed 4,167 times
3 Answers
7
refer first to this doc (section Externally Visible Server) on how to expose your local Flask
app to make it accessible from trusted devices in your network for testing purposes.
$(venv) flask run --host=0.0.0.0
or in your app.py
from flask import Flask
[..]
app = Flask(__name__)
[..]
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)
and then :
$(venv) python app.py
but if it happens and you got this error dial tcp 0.0.0.0:5000: connect: connection refused
then try to use the local ip address (192.168.x.y
instead of 0.0.0.0
) of the machine hosting your Flask
app. you may find this thread usefull

cizario
- 3,995
- 3
- 13
- 27
1
You can access your server on devices in the same Network / Wifi with your private IP address and the port.
On Mac OS option + click
on Wifi in your Taskbar.
On linux:
> ifconfig

sebastian-ruehmann
- 483
- 2
- 12
-
is this possible in any way to just copy the url of site and send it to my friend and it is available to him there by using url in flask ,That means a specific url/website related to that page without using my own device address – Gautam Goyal Jun 21 '20 at 15:30
-
you can take your public IP of your ISP, but consider, that usually these IPs are dynamically changing – sebastian-ruehmann Jun 21 '20 at 15:33
1
- Instead of localhost (127.0.0.1), you need to type your router's public IP. If you do not already know it, you can retrieve it by typing
ipconfig
(for Windows) orifconfig
(for Linux) in the command line. - You also need to disable your firewall or add an inbound rule for the port used by your server (e.g. 5000).

Glauvus
- 96
- 4
-
is this possible in any way to just copy the url of site and send it to my friend and it is available to him there by using url in flask ,That means a specific url/website related to that page without using my own device address – Gautam Goyal Jun 21 '20 at 15:26
-
You need to forward the inbound traffic to the required port. This can be done from the settings found on your router's interface (usually accessed on 192.168.1.1). Be aware that some ISPs are blocking spesific ports, so try to use a not well-known port. – Glauvus Jun 22 '20 at 09:23