1

I have a simple server on node.js running on GCE but I cannot reach the server externally. I'm not sure what is wrong as there is not much indications. Here is my code:

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var fs = require('fs');

app.use(function(req, res, next){
    console.log('Request Type:', req.method);
    console.log('Request query:', req.query);
    next();
});

app.use(bodyParser.urlencoded({     // to support URL-encoded bodies
  extended: true
}));

const PORT = 8080;

app.get("/getVideo", function (req, res){
  fs.readFile('./index.html', function (err, html){
     res.writeHead(200, {'Content-Type': 'text/html'});
     res.write(html);
     res.end();
   })
});


app.listen(PORT, '0.0.0.0');

I can ping the external ip exposed by GCE, but i just cannot reach it. Is there any other setup i need this to work? Or is the code incorrect?

mskw
  • 10,063
  • 9
  • 42
  • 64
  • 1
    Same as AWS, I hope you open a port 8080 for network traffic. If not follow this : http://stackoverflow.com/questions/21065922/how-to-open-a-specific-port-such-as-9090-in-google-compute-engine – Hiren S. Nov 30 '15 at 05:31

1 Answers1

1

I solved it from Hiren's comment. To go further, I've actually did what he said before, but the thing that did it was the tags. If you set something random, it would not work as it needs to match some other tags. But I left it empty just to test, and it applied it to all instances, and worked.

mskw
  • 10,063
  • 9
  • 42
  • 64