0

Trying to make the simplest "hello world" example of express server in node js , on a google VM machine and it does not work. What I am trying to do is NOT use the APP ENGINE of google , I am just trying as a 1st step to create a NODE JS server on the google compute machine and connect by http. I used the google code example of "hello world" for node js and to use the http://MY_VM_EXTERNAL_IP_ADDRESS:8080 to connect in the browser - no luck. I am sure I am missing something stupid but not sure what :-(.

'use strict';

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

app.get('/', (req, res) => {
  res.status(200).send('Hello, world!');
});

// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');
});
Gadi Ben Amram
  • 197
  • 1
  • 3
  • 13

1 Answers1

0

It is probably because the port is not open from the cloud side. I have never had to open the port from the OS side for node server, unless you have specially setup a firewall to do so.

In Azure, I had to go in the "Endpoints" section and add the port to open.

In AWS, I had to create an Inbound Rule in the Security Group

Google must have a similar setting. Refer to this answer

Community
  • 1
  • 1
Dushyant Bangal
  • 6,048
  • 8
  • 48
  • 80