小编Iva*_*ane的帖子

Github Actions 中拒绝连接到 postgres

我有一个带有 Postgres 默认数据库的 Django 应用程序,在 docker 中运行。我还使用 Github actions 作为 CI。当我使用命令在本地运行测试时

docker-compose run --rm app sh -c "python manage.py wait_for_db && pytest  -s -v"
Run Code Online (Sandbox Code Playgroud)

一切正常。但是,当我在 GitHub 操作中使用相同的命令时,出现以下错误:

E       django.db.utils.OperationalError: connection to server at "postgres" (172.18.0.2), port 5432 failed: Connection refused
E           Is the server running on that host and accepting TCP/IP connections?

/usr/local/lib/python3.10/site-packages/psycopg2/__init__.py:122: OperationalError
Run Code Online (Sandbox Code Playgroud)

这是我的 github 工作流程代码:

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions …
Run Code Online (Sandbox Code Playgroud)

django postgresql pytest docker github-actions

7
推荐指数
1
解决办法
3365
查看次数

标签 统计

django ×1

docker ×1

github-actions ×1

postgresql ×1

pytest ×1