首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sqitch无法连接到正在运行的Postgres实例

Sqitch无法连接到正在运行的Postgres实例
EN

Stack Overflow用户
提问于 2020-10-28 02:11:01
回答 1查看 162关注 0票数 0

我在OSX上有一个Postgres9.6实例,它已经启动并运行,但当我使用sqitch.conf在工作目录中尝试sqitch status时,Sqitch抛出以下错误

代码语言:javascript
复制
$ sqitch status
# On database db:pg:my_db
could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

这很奇怪,因为我已经通过检查Postgres的状态并直接登录来检查Postgres正在运行:

代码语言:javascript
复制
$ pg_isready 
/tmp:5432 - accepting connections

$ psql -U postgres
psql (9.6.19)
Type "help" for help.
postgres=#

这似乎只是sqitch的一个问题。

有关更多详细信息,此Postgres是通过brew install postgresql@9.6安装的,位于默认目录中:

代码语言:javascript
复制
$ which psql
/usr/local/opt/postgresql@9.6/bin/psql

关于Sqitch,我已经尝试过使用Homebrew安装和使用Docker (我目前的方法)。docker的安装是基于官方说明的:

代码语言:javascript
复制
docker pull sqitch/sqitch
curl -L https://git.io/JJKCn -o sqitch && chmod +x sqitch
./sqitch status

我也尝试过用sqitch config --user engine.pg.client /usr/local/opt/postgresql@9.6/bin/psql显式设置psql

无论如何,我仍然可以使用任何sqitch命令获得以下内容:

代码语言:javascript
复制
$ sqitch status
# On database db:pg:my_db
could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

我不确定我错过了什么,可以使用一些输入。提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2021-01-10 02:22:47

我不知道Brew安装的Sqitch出了什么问题,但当您从Docker镜像运行它时,该容器中没有运行Postgres,因此与localhost的连接将失败。相反,您需要连接到容器外部的Postgres。如果你在你的苹果电脑上运行它,这很简单:确保Postgres is listening on the IP ports,而不仅仅是一个Unix域套接字,和specify host.docker.internal as the host name,如下所示:

代码语言:javascript
复制
sqitch status db:pg://host.docker.internal/my_db
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64560488

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档