Home > Enterprise >  HTTP 500 error upon deploying application to Google App Engine
HTTP 500 error upon deploying application to Google App Engine

Time:10-17

I am using Google App Engine to deploy a test application. The deployment works fine and when I point my browser to the following URL, I receive an HTTP 500 error: https://test-gae-365706.uc.r.appspot.com/

My application code is as follows:

const http = require('http');

const port = 8080;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Do not have an inflated sense of yourself. You are just food for worms.');
});

server.listen(port, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

My app.yaml file is as follows:

runtime: nodejs10

My package.json file is as follows:

{
  "name": "app-engine",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "node app.js"
  },
  "engines": {
    "node": "10.x.x"  
  },
  "author": "",
  "license": "ISC"
}

When I run glcoud app deploy, I do not get any errors, but when I point my browser to the URL, I get the HTTP 500 error: Error: Server Error The server encountered an error and could not complete your request. Please try again in 30 seconds.

In the navigation pane, when I go to the Instances page, I see that no instance has been created. Could this be the problem?

Please let me know what is it that I am missing here.

CodePudding user response:

  1. You need a start script in package.json. Based on your test script, it would be something like -

"start": "node app.js"

See a sample Node App from Google

  1. You're using the variable ${hostname} but you haven't defined it. You need to define it and provide a value like you did for port
  • Related