8

Suppose that I have a Postgres cluster running, with its Unix domain socket located under /some/custom/path

How do I set up my database.yml so that the Rails app can connect to the cluster?

0

1 Answer 1

11

From the postgres docs:

host: Name of host to connect to. If this begins with a slash, it specifies Unix-domain communication rather than TCP/IP communication; the value is the name of the directory in which the socket file is stored.

The ActiveRecord adapter just passes through the host parameter so it's as simple as just putting this line in your database.yml:

host: /path/to/socket/file
Sign up to request clarification or add additional context in comments.

1 Comment

@MrMobster It's actually really unclear in the ActiveRecord docs and in the docs for the PG gem that combined they provide little more than a thin Ruby wrapper around libpq. I banged my head against this exact issue for a couple of hours once!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.