简体   繁体   中英

Can't access Google Cloud Compute engine external IP to access flask app

i've build a simple flask app on my google cloud GCE instance, but i can't access it from another computer, here's the simple flask app that i've build:

from flask import Flask, render_template, request, json, abort
app = Flask(__name__)
@app.route('/', methods=['GET'])
def heartbeat():
  return 'hello'
if __name__ == '__main__':
  app.run(host='0.0.0.0', port=5000)

and when i run the app

当我运行应用程序时

and access the external IP of my machine it only said this site can't be reached它只是说无法访问此站点 i have set up a new firewall rule设置新的防火墙规则 but it still not working.

这是因为您必须将端口更改为 80 而不是 5000

with me it was the silly problem that when you click on the link to the external IP on the GCP console you get send to https://34.##.#.## and that doesn't work but if you go to 34.##.#.##:5000 it did work for me. Also doing a "curl 34.##.#.##:5000" on linux also works for me

When I did this my problem was I didnt configure the windows firewall correctly at first. Make sure to allow inbound rules like this:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM