python - 错误,“[错误] 33#33: *92500 connect() failed (111: Connection denied) while connection to upstream, client: 216.58.212.244, server: #1906
问题描述
尝试使用 FastAPI 在 App Engine 上托管 API,最初使用的是 Flask,它可以工作但速度很慢。我现在收到以下错误:error, "[error] 33#33: *92500 connect() failed (111: Connection refused) while connecting to upstream, client: 216.58.212.244, server:
这是 app.yaml 文件:
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
这是主脚本,必须删除大部分代码:
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}
解决方案
您将应用程序绑定在 127.0.0.1 网络接口上,这意味着它只能在 localhost 上访问。
要使您的应用程序绑定到所有可用的网络接口,您可以使用 0.0.0.0
entrypoint: uvicorn --host 0.0.0.0 --port 8080 --timeout-keep-alive 500 main:app
推荐阅读
- vue.js - 在 vue js 中将类作为道具传递?
- android-layout - SwitchCompat 文本未显示在操作栏上
- schedule - 在套件脚本 2.0 中找不到函数 setValue?
- javascript - Sapper 不导出 *.json.js 文件
- android - 添加firebase性能依赖后Gradle依赖冲突
- java - 在不使用 apache CompareToBuilder 的情况下实现我自己的 compareTo()
- jenkins - 如何在 Jenkins 的控制台输出中提取错误?
- javascript - 将组件传递给 useState() 钩子
- python - 函数调用子函数满足条件
- python - Python 函数调用 vs 数据库查询(django ORM)开销