简体   繁体   English

无法访问谷歌云计算引擎外部 IP 以访问 flask 应用程序

[英]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:我在我的谷歌云 GCE 实例上构建了一个简单的 flask 应用程序,但我无法从另一台计算机访问它,这是我构建的简单 flask 应用程序:

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并访问我机器的外部 IP 它只说无法访问此站点它只是说无法访问此站点 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.对我来说,这是一个愚蠢的问题,当您在 GCP 控制台上单击指向外部 IP 的链接时,您会发送到 https://34.##.#.## 并且这不起作用但是如果您去34.##.#.##:5000 它确实对我有用。 Also doing a "curl 34.##.#.##:5000" on linux also works for me在linux上做一个“curl 34.##.#.##:5000”也对我有用

When I did this my problem was I didnt configure the windows firewall correctly at first.当我这样做时,我的问题是我一开始没有正确配置 windows 防火墙。 Make sure to allow inbound rules like this:确保允许这样的入站规则:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用 Apache 将 sklearn 导入 Google Compute Engine 上的 Flask App - Can’t Import sklearn into Flask App on Google Compute Engine with Apache 如何在Google Compute Engine中通过Python访问Google Cloud SQL - How to access Google Cloud SQL by Python in Google Compute Engine 如何从Google Compute Engine访问外部SFTP - How to access an external SFTP from Google Compute Engine 无法使用 sshtunnel 将 SSH 发送到 Google Cloud Compute Engine - Can't SSH to Google Cloud Compute Engine with sshtunnel 无法访问通过Docker和Google Cloud部署的应用 - Can't access app deployed with docker and google cloud 从python + flask + gunicorn + nginx + Compute Engine应用程序中读取来自Google Cloud Storage的文件失败 - Reading of a file from Google Cloud Storage fails in a python + flask + gunicorn + nginx + Compute Engine app 从App Engine连接到Google Cloud SQL:拒绝访问 - Connecting to Google Cloud SQL from App Engine: access denied 从应用引擎访问谷歌云存储帐户对象 - Access google cloud storage account objects from app engine 无法绑定到谷歌计算引擎虚拟机实例的外部 IP 地址 - Cannot bind to external IP address of google compute engine VM instance Google Cloud Datastore 和 Flask App Engine - Google Cloud Datastore and Flask App Engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM