error, "[error] 33#33: *92500 connect() failed (111: Connection refused) while connecting to upstream, client: 216.58.212.244, server: #1906

Viewed 165

Trying to host an API on App Engine using FastAPI, was originally using Flask which was working but very slow. I'm now getting the following error: error, "[error] 33#33: *92500 connect() failed (111: Connection refused) while connecting to upstream, client: 216.58.212.244, server:

This is the app.yaml file:

runtime: python
env: flex

entrypoint: uvicorn --host 127.0.0.1 --port 8080 --timeout-keep-alive 500 main:app
service: default

instance_class: F4_1G

# Instance Class: F4_1G
# Memory Limit: 2048 MB
# CPU Limit: 2.4 GHz
# Supported Scaling Types: Automatic

runtime_config:
    python_version: 3

handlers:
- url: /.*
  script: auto

network:
  forwarded_ports:
   - 8080

This is the main script, the majority of the code has had to be removed:

import uvicorn
from fastapi import FastAPI, Request
app = FastAPI()

@app.get('/')
async def nlp_email(return_method : str,
                    user_email    : str,
                    filename      : str)

    return {'html': html}
1 Answers

You're binding your application on 127.0.0.1 network interface, which means it can only be accessed on localhost.

To make your application bind on all available network interfaces you can use 0.0.0.0

entrypoint: uvicorn --host 0.0.0.0 --port 8080 --timeout-keep-alive 500 main:app
Related