title: Server error 500 when deploying NodeJS Express app on GCP App Engine
body: <p>I'm trying to deploy a NodeJS app on gcloud that runs my express api. When I run npm start locally I get this message:</p>
  <pre><code>&gt;npm start
  
  &gt; my_api@1.0.0 start E:\My_Project\My_API
  &gt; node index.js
  
  Running API on port 8080
  Connected to DB!
  </code></pre>
  <p>So I created an app.yaml file with the following properties:</p>
  <pre><code>runtime: nodejs12
  entrypoint: npm start
  
  manual_scaling:
    instances: 1
  resources:
    cpu: 1
    memory_gb: 0.5
    disk_size_gb: 10
  </code></pre>
  <p>Then I run gcloud app deploy, and everything is deployed properly to the correct project with no errors. But when I go to the base url, I get:</p>
  <pre><code>Error: Server Error
  
  The server encountered an error and could not complete your request.
  
  Please try again in 30 seconds.
  </code></pre>
  <p>So I checked the logs with <code>gcloud app logs tail -s default</code>, and I'm noticing the app keeps restarting over and over endlessly:</p>
  <pre><code>2020-12-08 00:10:21 default[...]  &gt; node index.js
  2020-12-08 00:10:21 default[...]
  2020-12-08 00:10:21 default[...]  Running API on port 8081
  2020-12-08 00:10:29 default[...]  &quot;GET /_ah/start HTTP/1.1&quot; 302
  2020-12-08 00:10:31 default[...]
  2020-12-08 00:10:31 default[...]  &gt; my_api@1.0.0 start /workspace
  2020-12-08 00:10:31 default[...]  &gt; node index.js
  2020-12-08 00:10:31 default[...]
  2020-12-08 00:10:31 default[...]  Running API on port 8081
  2020-12-08 00:10:41 default[...]  &quot;GET /_ah/start HTTP/1.1&quot; 302
  2020-12-08 00:10:43 default[...]
  2020-12-08 00:10:43 default[...]  &gt; my_api@1.0.0 start /workspace
  2020-12-08 00:10:43 default[...]  &gt; node index.js
  2020-12-08 00:10:43 default[...]
  2020-12-08 00:10:43 default[...]  Running API on port 8081
  2020-12-08 00:10:59 default[...]  &quot;GET /_ah/start HTTP/1.1&quot; 302
  ...
  </code></pre>
  <p>If I try a specific endpoint, I get these outputs (for one call):</p>
  <pre><code>2020-12-08 01:05:57 default[...]  &quot;GET /my_api/some_endpoint HTTP/1.1&quot; 500
  2020-12-08 01:05:58 default[...]  &quot;GET /favicon.ico HTTP/1.1&quot; 500 &lt;-- not sure what this is about
  </code></pre>
  <p>Also, I noticed that unlike in my local run, the gcloud app never outputs &quot;Connected to DB!&quot; which happens upon importing my database module into the routes.js file. Besides the app.yaml though, there's nothing different from running the app locally and on app engine, I'm just not sure why the app keeps restarting over and over every few seconds.</p>
  <p>EDIT: So I noticed that, by default, app engine queries /_ah/start and /favicon.ico upon starting up the api, but since I don't have those endpoints coded, it errors and restarts. Is there any way to remove those two, or are they necessary for app engine to determine the app is working? OR at least I could add a /favicon.ico and /_ah/start endpoints, but what is the response format supposed to look like for it to respond? (I tried just returning 200 for both, but still get the same behavior)</p>