我正在尝试迁移macOS蒙特雷12.3上的django项目,我遇到了一些麻烦。
似乎psycopg2根本不想连接到我的码头容器。每次打印此错误时:
django.db.utils.OperationalError: connection to server at "localhost" (127.0.0.1), port 5433 failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
对于我的停靠程序,我通过运行
docker run --name local-postgres -p 5433:5433 -e POSTGRES_PASSWORD=test123 -d postgres
我正在使用pipenv在虚拟环境中运行python3.9.12,对于任何想知道的人来说,我的arch是arm64。
我尝试过更改端口,我尝试重新设置,完全删除并下载它,重新安装django和重新安装venv,到目前为止都没有任何效果。我也尝试过在设置中设置CONN_MAX_AGE=0
,但这没有起作用。
请帮帮忙
发布于 2022-03-29 18:51:54
Postgres监听端口5432,因此需要将其映射到主机上要连接的端口。看起来你想要使用端口5433,所以你可以
docker run --name local-postgres -p 5433:5432 -e POSTGRES_PASSWORD=test123 -d postgres
然后可以使用本地主机端口5433在主机上进行连接。
https://stackoverflow.com/questions/71667338
复制相似问题