-1

I am trying to allow remote connections to my FlaskApp. The scope is to have my FlaskApp running for example on the cloud and me being able to access data from my phone ecc. But I can only run it for Local Host.

I tried with following code:

from flask import Flask, request
app=Flask(__name__)
MY_IP="" #server IP:port

@app.route("/testing")
def test():
   return "TEST"

app.run(MY_IP, debug=True)

But I keep getting following error:

line 795, in run_simple
    s.bind(get_sockaddr(hostname, port, address_family))
socket.gaierror: [Errno 11001] getaddrinfo failed

Would be really kind if someone could help me out. I also tried entering just the IP address instead of the IP:PORT but i still kept getting that error.I also read using 0.0.0.0 could help, but didn't work either

rocket
  • 217
  • 5
  • 16
  • 1
    Have you tried 0.0.0.0 as an IP? – RaisinBranCrunch Apr 20 '19 at 20:01
  • @RaisinBranCrunch yes, can just access locally with 0.0.0.0 – rocket Apr 20 '19 at 20:02
  • have you tried without args? – Miguel Apr 20 '19 at 20:14
  • server should use `0.0.0.0` - but it is information to use all network card in computer and every card has own IP. Client in local network should access it but it has to use IP of server's network card, not `0.0.0.0` – furas Apr 20 '19 at 20:36
  • If you want to run on local computer and get access from internet then you have different problem - provider's routers. They would have to redirect port 80 (and your external IP) to your server but they never do this. Solution can be external server on internet or at least ngrok. – furas Apr 20 '19 at 20:38
  • This has already answered here. https://stackoverflow.com/questions/7023052/configure-flask-dev-server-to-be-visible-across-the-network – Asif Akhtar Apr 20 '19 at 20:19

1 Answers1

1

You can use something like ngrok. Keep in mind that it's still not a good idea to expose Flask's development server publicly.

It's a tool that creates public URLs for exposing your local web server. You just specify the port you want to expose using their command line tool, and ngrok will do the rest.

For instance, assuming your server is listening on port 5000:

ngrok http 5000
davidism
  • 121,510
  • 29
  • 395
  • 339
Games Brainiac
  • 80,178
  • 33
  • 141
  • 199