title: Flask app returns a "502: Bad Gateway" because Google Sloud SDK thinks the port is in use (it's [probably] not)
body: <p>I'm trying to deploy a fairly simple Flask app with a couple views using Google's App Engine. As far as I know, nothing is wrong with the Flask code itself - it runs just fine on a local port. The problem, however, occurs when I cd into the project directory and run "gcloud app deploy." The app deploys without any errors and returns a 502 code when I go into the .appspot.com domain reserved for the app.</p>
  
  <p>I was a little confused, so I ran "gcloud app logs tail." This is the message that is displayed on repeat in the logs:</p>
  
  <pre><code>* Serving Flask app "main" (lazy loading)
  * Environment: production
  WARNING: Do not use the development server in a production environment.
  Use a production WSGI server instead.
  * Debug mode: on
  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
  [2019-01-06 23:55:00 +0000] [240] [INFO] Starting gunicorn 19.9.0
  [2019-01-06 23:55:00 +0000] [240] [ERROR] Connection in use: ('', 8081)
  [2019-01-06 23:55:00 +0000] [240] [ERROR] Retrying in 1 second.
  [2019-01-07 23:55:01 +0000] [240] [ERROR] Can't connect to ('', 8081)
  </code></pre>
  
  <p>Running "netstat -ano" shows no processes that are actually using port 8081. Running netstat and killing whatever process was using the occupied port was suggested in a post with a problem similar to mine. However, there's literally nothing using 8081 here. </p>
  
  <p>"main" is main.py, a file that creates an app, registers all the blueprints, and runs the app with</p>
  
  <pre><code>app.run(host="0.0.0.0", debug=True)
  </code></pre>
  
  <p>I'm totally new to using the App Engine - am I missing something? Anyone know where to start?</p>