Discourse Randomly Does Not run or Rebuild

I don’t think it’s related to your issue. This warning often (always?) appear during a rebuild.

error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: Connection refused

I think your issue more likely comes from this.