1
votes

I am trying some hands-on on Google Cloud Platform, App Engine in specific.

For the same, I've created a simple nodejs application which just send Hello Wold message in the response.

But I am unable to access the endpoint and getting the below error enter image description here

below are my files:

aap.yaml

runtime: nodejs
env: flex

index.js

'use strict';

const http = require('http');
const port = 443;

const requestHandler = (request, response) => {
  console.log(request.url);
  response.end('Hello Node.js Server!');
}


const server = http.createServer(requestHandler);
server.listen(port, (err) => {
  if (err) {
    return console.log('something bad happened', err)
  }
  console.log(`server is listening on ${port}`)
});

package.json

{
  "name": "test-pro-for-gcm",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "deploy": "gcloud app deploy",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

UPDATE 1 In the GCP log, 16:31:59.000 server is listening on 443

1
Hey i have been having the same error since Saturday. Will be watching the thread here hopefully we get a feedback.Elio Khattar
I had created this application from myself and was getting error. Now I'm deploying hello-world demo app and it's working as expected. You can download the demos from here codeload.github.com/GoogleCloudPlatform/nodejs-docs-samples/zip/…Vivek Kumar

1 Answers

0
votes

The port that will receive HTTP requests is 8080.

Use the PORT environment variable in your code to make it compatible with the App Engine environment: const port = process.env.PORT || 443;