For my company I need to develop some features against our Discourse instance’s REST API. For local development and testing I’ve been following Install Discourse for development using Docker successfully for quite some time now.
It’s been a few weeks since I’ve last been developing. Yesterday I wanted to fire up Discourse locally again so I did my usual git pull && d/boot_dev && d/bundle install && d/rails s
. However, the last command d/rails s
fails with the following error:
URGENT: Failed to initialize site default: ActiveRecord::ConnectionNotEstablished connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
/home/discourse/.bundle/gems/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:69:in `rescue in new_client'
[...]
When I open a Terminal into the discourse_dev container and do a ls -la /var/run/postgresql/
I can see that there is indeed no .s.PGSQL.5432
socket in here.
Ok, so I thought maybe I shouldn’t have blindly done a git pull
first, so I checked out tag v4.4.0 and even tag v3.3.0 and tried again. But I’m getting the exact same error.
It looks to me as if the Postgres Database is not running inside the discourse_dev container?
The weird thing is: If I clone the discourse repo into a new folder (yes, even the latest code in the main branch) and fire up Discourse using Docker I’m not getting this error and Discourse starts successfully.
But of course I have an empty database then which is a bit unfortunate. I understand that the data is persisted inside tmp/postgres, which I can copy over from the old folder into the new one. But I can’t do that anymore because I didn’t know that yesterday, and in my yesterday’s troubleshooting attempts I deleted every temporary folder and the node_modules and the .pnpm-store folder and so on. But the problem still persists.
Does anybody have a clue what is happening here or what I can do to troubleshoot this?