简体   繁体   English

无法在GoogleCloud VM中打开端口

[英]Unable to open port in GoogleCloud VM

I hosted a Flask API in google cloud VM having 16.04 LTS Ubuntu OS through the port 5000. VM has both private IP and public IP assigned to it and have created a firewall rule for opening the 5000 port. 我通过端口5000在具有16.04 LTS Ubuntu OS的google cloud VM中托管了FlaskAPI。VM为它分配了专用IP和公用IP,并创建了用于打开5000端口的防火墙规则。 I am able to access the API by logging in to the VM. 我可以通过登录VM来访问API。 But when I tried to access it using public IP I was not able to do it and I get the following error:- Failed to connect to 35.200.001.01 port 5000: No route to host What should I do to expose APIs publicly? 但是,当我尝试使用公用IP访问它时,却无法执行以下操作并收到以下错误:-无法连接到35.200.001.01端口5000:无主机路由我应该怎么做才能公开公开API? Have provided the screenshot of firewall configuration for your reference. 提供了防火墙配置的屏幕快照,以供您参考。

在此处输入图片说明

add tcp:5000 instead of all protocols and ports (which would take down the firewall)... in case it still not works, once check inside the instance, if the port on the external interface can be accessed. 添加tcp:5000而不是all协议和端口(这将占用防火墙)...如果仍然无法使用,请在实例内部检查一次是否可以访问外部接口上的端口。 Flask binds per default to IP 127.0.0.1:5000 - while it should be 0.0.0.0:5000 , so that one could access it from the localhost, internal and external interfaces. 默认情况下,Flask绑定到IP 127.0.0.1:5000它应该是0.0.0.0:5000 ,以便人们可以从localhost,内部和外部接口访问它。

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

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