Your Pg gem is using a libpq
version that defaults to a different unix_socket_directory
to the one your new server uses. Most likely your new server uses /tmp
and your old one used /var/run/postgresql
.
You can force a TCP/IP connection by specifying localhost
as the target host to connect to, e.g a connstring like dbname=fred host=localhot user=bob
, or however you're giving the parameters to the Pg gem. That's not really the best answer, though.
Instead, you should either:
- Rebuild the
pg
gem against the updatedlibpq
from your new PostgreSQL install. To do that, setPATH
so that thepg_config
from the new PostgreSQL install is first on the path before rebuilding the Pg gem. You can check the version withpg_config --version
.
or
- Specify the
unix_socket_directory
to connect to explicitly, withhost=/tmp dbname=fred user=bob
. Thehost
parameter can take a hostname or a path to a socket directory. Doing this means you're still using nice efficient unix sockets for your sessions and not paying unnecessary TCP/IP overheads.