# 无法重建 Discourse：GCP 上的 GitHub 连接错误和端口 443 问题

**URL:** https://meta.discourse.org/t/unable-to-rebuild-discourse-github-connection-error-and-port-443-issues-on-gcp/385108
**Category:** Self-hosting
**Created:** [2025 年10 月 9 日 05:17 UTC](https://meta.discourse.org/t/unable-to-rebuild-discourse-github-connection-error-and-port-443-issues-on-gcp/385108 "2025-10-09T05:17:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### 作者： ![devrim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/devrim/32/524580_2.png) [@devrim](https://meta.discourse.org/u/devrim)
#### 发布日期： [2025 年10 月 9 日 05:17 UTC](https://meta.discourse.org/t/unable-to-rebuild-discourse-github-connection-error-and-port-443-issues-on-gcp/385108/1 "2025-10-09T05:17:10Z")

</div>

您好，Discourse 社区，

我在 Google Cloud Platform (GCP) 虚拟机（Ubuntu 22.04，16GB RAM，8 个 CPU 核心）上重建 Discourse 实例时遇到问题。重建因 GitHub 连接错误而失败，并且我还遇到了端口 443 可访问性问题。我已经尝试了几个步骤，但仍然卡住了，希望得到您的帮助。

重建期间的 GitHub 连接错误

运行 `./launcher rebuild app` 或 `./discourse-setup` 时，重建会因日志中的以下错误而失败：

```plaintext
fatal: unable to access ’ https://github.com/discourse/discourse.git/ ': Failed to connect to github.com port 443 after 3 ms: Couldn’t connect to server

Pups::ExecError: cd /var/www/discourse &amp;&amp; sudo -H -E -u discourse bash -c ‘… git fetch …’ failed with return #&lt;Process::Status: pid 145 exit 128&gt;

```

但是，从主机测试 GitHub 连接正常：

```plaintext
curl -I https://github.com

HTTP/2 200

```

但在以 discourse 用户身份运行时失败：

```plaintext
sudo -u discourse -H git ls-remote https://github.com/discourse/discourse.git

fatal: unable to access ’ https://github.com/discourse/discourse.git/ ': Failed to connect to github.com port 443 after 3 ms: Couldn’t connect to server

```

[github.com](http://github.com) 的 DNS 解析正常：

```plaintext
sudo -u discourse -H nslookup github.com 8.8.8.8

Server: 8.8.8.8

Address: 8.8.8.8#53

Name: github.com

Address: 192.30.255.113

```

---

<div class="post-metadata">

### 作者： ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### 发布日期： [2025 年10 月 9 日 12:59 UTC](https://meta.discourse.org/t/unable-to-rebuild-discourse-github-connection-error-and-port-443-issues-on-gcp/385108/2 "2025-10-09T12:59:33Z")

</div>

您是否启用了防火墙？它可能是罪魁祸首。

> [@devrim](#):
>
> 当 discourse 用户失败时：

那是在容器里面吗？与主机相比，Docker 可能应用了不同的防火墙规则。

---

<div class="post-metadata">

### 作者： ![devrim](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/devrim/32/524580_2.png) [@devrim](https://meta.discourse.org/u/devrim)
#### 发布日期： [2025 年10 月 9 日 14:07 UTC](https://meta.discourse.org/t/unable-to-rebuild-discourse-github-connection-error-and-port-443-issues-on-gcp/385108/3 "2025-10-09T14:07:14Z")

</div>

我之前在 Google Cloud 上设置过几次自托管。但是，我上一次尝试，也就是一周前，没有成功。它一直给我 443 和 GitHub 数据路径错误，而且我无法重建。

---

<div class="post-metadata">

### 作者： ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### 发布日期： [2025 年10 月 9 日 15:01 UTC](https://meta.discourse.org/t/unable-to-rebuild-discourse-github-connection-error-and-port-443-issues-on-gcp/385108/4 "2025-10-09T15:01:03Z")

</div>

> [@devrim](#):
>
> `Failed to connect to github.com port 443 after 3 ms`

它仅在 3 毫秒后就无法连接的事实意味着问题出在主机或非常接近主机的地方。

您在主机上做了哪些更改？您是否启动了防火墙？也许它正在覆盖 docker 所必需的转发规则。

从检查容器的 IP 连接性开始。
