Unable to connect to PostgreSQL despite configuration

Hi all. I have a fresh 2.4.5 install, not upgrade. When I try to run any database-interacting Rake command, I get this error:

rake aborted!
PG::ConnectionBad: 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"?

Googling, it looks like that most often means that PostgreSQL itself has fallen over and needs to be restarted. That’s not the case here, however; PostgreSQL is running on a separate container, and I can connect to it manually over the network just fine.

Of note, it’s trying to connect over a local socket. However, config/discourse.conf specifically lists a PostgreSQL instance to connect to by host and port, with username/password. (The same credentials I use to connect manually.)

That to me suggests that… discourse.conf is just not being read at all? So it’s falling back to a localhost connection over unix socket, which of course doesn’t work because there is no local db? That’s my best guess, but I don’t know if it’s right or how to fix it if it is.

Can anyone point me in the right direction?

Why are you looking into this file? Is this a production install using Discourse official Standard Installation?

1 Like

If you did do a standard install, did you include the web.socketed.template.yml for some reason?

No, this isn’t a Docker environment. (Different host.) It’s a git clone of the tag, plus some edits such as adding the DB credentials and setting force_https to true.

@pfaffman There is no web.socketed.template.yml file found.

The confusing thing is, I had this working earlier, or at least this part of it. Then I moved it to a subdirectory (and updated the webserver config to point to it) and now it wont’ talk to the database. How one impacts the other I do not understand.

(Technically this is a build process for another host that doesn’t use Docker. I’m trying to setup a one-click install template of Discourse, and it’s… proving difficult.)

Yup. It’ll require a whole bunch of specific knowledge about Discourse that you probably don’t have and a bunch of specific knowledge about your local environment that no one here has. Best of luck.

I’m tagging unsupported-install.

3 Likes

Yeah, unfortunately there is a limit to what we can support here for our own sanity as an organization, and this sounds like a complex install indeed.

4 Likes