1

I have a Postgres 9.6 instance on OSX that is up and running, but Sqitch throws the following error when I try sqitch status in a working directory with a sqitch.conf:

$ 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"?

This is odd because I have already checked that Postgres is running by checking its status and logging in directly:

$ pg_isready 
/tmp:5432 - accepting connections

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

This seems to be just a problem with sqitch.

For more detail, this Postgres was installed via brew install postgresql@9.6 and is located in the default directory:

$ which psql
/usr/local/opt/postgresql@9.6/bin/psql

Regarding Sqitch, I have tried both installing with Homebrew and using Docker (my current approach). The docker install is based on the official instructions:

docker pull sqitch/sqitch
curl -L https://git.io/JJKCn -o sqitch && chmod +x sqitch
./sqitch status

I tried setting psql explicitly as well with sqitch config --user engine.pg.client /usr/local/opt/postgresql@9.6/bin/psql

Regardless, I still get the following with any sqitch command:

$ 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"?

I'm not sure what I'm missing and could use some input. Thanks in advance.

J-Deq87
  • 101
  • 10
  • See `connections on Unix domain socket /var/run/postgresql/.s.PGSQL.5432` vs `/tmp:5432 - accepting connections`. That usually happens when programs are compiled or linked against different versions of `libpq`. I would try changing your connection to point at `localhost` instead of a socket(local). – Adrian Klaver Oct 27 '20 at 20:52

1 Answers1

2

I don't know what's up with the Brew-installed Sqitch, but when you run it from the Docker image, that container does not have Postgres running inside it, so connections to localhost will fail. You instead need to connect to Postgres outside the container. If you're running it on your Mac, this is straightforward to do: Make sure Postgres is listening on the IP ports, not just a Unix domain socket, and specify host.docker.internal as the host name, like so:

sqitch status db:pg://host.docker.internal/my_db
theory
  • 9,178
  • 10
  • 59
  • 129