堆栈:Ubuntu (20.04 LTS) Nginx Postgresql (v13.3) AWS 负载均衡器将流量发送到 Ubuntu 实例(k8s 集群),由 Nginx 处理,转发到在 Gunicorn (19.9) 中运行的 Django (4.0.3) .0)。Django 使用 psycopg2 (2.8.6) 连接到数据库。我遇到的问题是数据库连接似乎随机关闭。
Django 报告这样的错误:
`InterfaceError: connection already closed
File "django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "contextlib.py", line 79, in inner
return func(*args, **kwds)
File "django/views/generic/base.py", line 84, in view
return self.dispatch(request, *args, **kwargs)
File "django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "django/views/decorators/cache.py", line …Run Code Online (Sandbox Code Playgroud)