# 在使用 Docker 本地运行 Discourse 时，Postgres 似乎没有在运行

**URL:** <https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539>\
**Category:** Support\
**Created:** [2025年二月21日 07:47 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539 "2025-02-21T07:47:39Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![GregorSondermeier](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gregorsondermeier/32/299039_2.png) [@GregorSondermeier](https://meta.discourse.org/u/GregorSondermeier)\
**Post date:** [2025年二月21日 07:47 UTC](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539/1 "2025-02-21T07:47:39Z")

</div>

为了我的公司，我需要针对 Discourse 实例的 REST API 开发一些功能。对于本地开发和测试，我一直在成功地遵循 [Install Discourse for development using Docker](https://meta.discourse.org/t/102009%E3%80%82)

我已经几周没有进行开发了。昨天我想再次在本地启动 Discourse，所以我执行了我平常的 `git pull && d/boot_dev && d/bundle install && d/rails s` 命令。然而，最后一个命令 `d/rails s` 因以下错误而失败：

```bash
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'
[...]\

```

当我进入 _discourse\_dev_ 容器并执行 `ls -la /var/run/postgresql/` 时，我可以看到这里确实没有 `.s.PGSQL.5432` 套接字。

好的，所以我想也许我不应该盲目地先执行 `git pull`，所以我签出了 [tag v4.4.0](https://github.com/discourse/discourse/tree/v3.4.0) 甚至 [tag v3.3.0](https://github.com/discourse/discourse/tree/v3.3.0) 并再次尝试。但我遇到了完全相同的错误。

在我看来，Postgres 数据库似乎没有在 _discourse\_dev_ 容器中运行？

奇怪的是：如果我将 [discourse 仓库](https://github.com/discourse/discourse) 克隆到一个新文件夹中（是的，即使是 _main_ 分支中的最新代码），并使用 Docker 启动 Discourse，我不会遇到此错误，并且 Discourse 会成功启动。  
但当然，我的数据库是空的，这有点不幸。我明白数据会持久化在 _tmp/postgres_ 中，我可以从旧文件夹复制到新文件夹。但昨天我不知道这一点，并且在我昨天的故障排除尝试中，我删除了所有临时文件夹以及 _node\_modules_ 和 _.pnpm-store_ 文件夹等等。但问题仍然存在。

**有人知道这里发生了什么或者我该如何解决这个问题吗？**

---

_[View the full topic](https://meta.discourse.org/t/postgres-doesnt-seem-to-be-running-when-running-discourse-locally-using-docker/353539)._
