简体   繁体   English

Google Cloud Compute Engine-Node.js无法正常工作

[英]Google Cloud Compute Engine - Nodejs not working

I created a free server from Google Cloud. 我从Google Cloud创建了一个免费服务器。 I want to run Node.js on this server. 我想在此服务器上运行Node.js。 I installed Node.js. 我安装了Node.js。 I installed Express and created a project. 我安装了Express并创建了一个项目。 Then I run the project (working). 然后,我运行项目(正在运行)。

But I can not get the output by typing ip-address: 3000. "This site can not be reached." 但是我无法通过输入ip-address:3000获得输出。“无法访问此站点。” I get as a result. 结果我得到了。

What could be the reason for that. 这可能是什么原因。

I just setup one to see how this works, how i setup the server, hope this helps: 我只是设置一个,以查看其工作原理,服务器设置方式,希望对您有所帮助:

var express = require('express');
var app = express();

app.get('/', (req, res) => {
    res.json('Home Page');
})

app.listen(8080);

The web applications must listen for HTTP requests on ports within the permitted range 8080 to 8084.....To connect to a web application running on an instance, click the Web Preview button Web Preview Button above the Cloud Shell terminal window in the GCP Console. Web应用程序必须在允许的8080到8084范围内的端口上侦听HTTP请求。....要连接到实例上运行的Web应用程序,请单击GCP中Cloud Shell终端窗口上方的Web预览按钮Web预览按钮安慰。 src: https://cloud.google.com/shell/docs/features#web_preview src: https//cloud.google.com/shell/docs/features#web_preview

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

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