I'm new to GCP, we had chosen sanic framework to make things run smoother. Sanic supports python 3.5+ so we are going with flexible environment on appengine.

Currently I'm trying to deploy "Sanic" Hello world (Get started) application to appengine. and stuck config. problem at

# This looks like a Python app.  If so, please enter the command to run 
the app in production (enter nothing if it's not a python app): :

I had looked into other Google Cloud Platform (Python docs samples) examples which are available on GitHub all were using gunicorn but sanic has builtin http server.

Can someone suggest app.yaml model for sanic on appengine. my current setup follows as

1. app.yaml

    runtime: python
env: flex
threadsafe: true

  python_version: 3

- url: .*  # This regex directs all routes to main.app
  script: main.app

2. main.py

#import logging
from sanic import Sanic
from sanic.response import json

app = Sanic()

async def test(request):
    return json({"hello": "world"})

if __name__ == "__main__":
    app.run(host="", port=8000)

3. requirements.txt



added entrypoint: python main.py to app.yaml fixed my deploy problem but appengine throughs error.

Error: Server Error
The server encountered a temporary error and could not complete your request. Please try again in 30 seconds.

Thanks in advance. and if you cant solve my problem don't down vote.

  • The "temporary error" message usually means that the instances are still deploying. Have you checked in the Cloud Console under "Compute Engine" to see the state of the Flexible Environment host VMs? – Nick Apr 28 '17 at 20:04
  • @Nick I had verified that instances are spinning and up.... Any other suggestions? – cutiehulk2329 May 7 '17 at 17:37
  • Are you exposing port 8000? The default is port 8080, so it's possible that's the only issue. – Nick May 10 '17 at 18:59
  • @cutiehulk2329 Were you able to find the solution to your question? If so it is recommended that you post it as the answer to help the community. If not, you can provide the additional information requested by Nick to further the investigation. – Jordan May 29 '17 at 19:13

To be exact here is the appengine app.yaml entrypoint model:

entrypoint: gunicorn <main:app> --bind --worker-class sanic.worker.GunicornWorker

You need to make sure to install gunicorn pip packages. Currently Appengine supports gunicorn version 19.7.1.

  • Worked for me, but without <>. gunicorn main:app --bind --worker-class sanic.worker.GunicornWorker – enf644 Mar 15 '19 at 14:05

I am not sure if the following is helpful.

I had the same problem. Solved by:

  1. adding entrypoint: gunicorn -b :$PORT main:app to my app.yaml file.
  2. adding "gunicorn==19.7.1" to my requirements.txt file.

Just change the main to be like this:

if __name__ == '__main__':
    app.run(host='', port=os.environ.get('PORT',8080))

and the app.yaml entrypoint to:

entrypoint: python main.py

It should work.


For me it works. I just change what I wrote above, and deploy the new version to GAE-Flex.

  • Please elaborate a little bit about why "it should work". – chutz Apr 1 '19 at 6:16
  • @chutz Just deploy the new version with the changes to GAE-Flex – Eldad Cohen Apr 2 '19 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.