{"meta":{"title":"GitHub Codespaces 连接疑难解答","intro":"有关连接到 GitHub Codespaces 的故障排除帮助。","product":"Codespaces","breadcrumbs":[{"href":"/zh/codespaces","title":"Codespaces"},{"href":"/zh/codespaces/troubleshooting","title":"故障排除"},{"href":"/zh/codespaces/troubleshooting/troubleshooting-your-connection-to-github-codespaces","title":"连接"}],"documentType":"article"},"body":"# GitHub Codespaces 连接疑难解答\n\n有关连接到 GitHub Codespaces 的故障排除帮助。\n\n## 503 Codespace服务不可用\n\nCodespaces 设置为在无任何活动 30 分钟后停止。 如果你在 codespace 停止后尝试与其交互，你可能会看到 `503 service unavailable` 错误。\n\n* 如果“ **开始”** 按钮显示在 Visual Studio Code 浏览器窗口中或浏览器中，请单击“ **开始** ”以重新连接到代码空间。\n* 通过重新加载窗口来重置代码空间。 在[命令面板中](/zh/codespaces/reference/using-the-vs-code-command-palette-in-codespaces#accessing-the-vs-code-command-palette)Visual Studio Code，单击“**开发人员：重载”窗口**。\n\n## 浏览器无法连接\n\n有时，您可能无法从浏览器访问代码空间。 如果发生这种情况，请转到 <https://github.com/codespaces> 并尝试从该页面连接到 codespace。\n\n* 如果该页面上未列出代码空间，请检查您是尝试连接到的代码空间的所有者。 您只能打开自己创建的代码空间。\n* 如果列出了代码空间，但您无法从该页面进行连接，请检查是否可以使用其他浏览器进行连接。\n\n### 通过错误消息进行诊断\n\n#### “很不幸，你似乎已离线”\n\n检查你的互联网连接是否稳定，并且你的公司网络是否未阻止连接。 如果可能，请检查设备上是否有被拒绝连接的日志记录。\n\n如果看到被拒绝的连接，请确保防火墙不会阻止 `/meta` REST API 终结点记录的域。 有关详细信息，请参阅“[元数据的 REST API 端点](/zh/rest/meta/meta#get-github-meta-information)”。\n\n若要获取 GitHub Codespaces 所需的域名列表，请使用 GitHub CLI 执行以下命令：\n\n`gh api meta --jq .domains.codespaces`\n\n### “我们在提取您的代码空间信息时遇到问题。”\n\n这是一个暂时性错误。 请在等待几分钟后重试。\n\n### “我们无法完成连接的身份验证”\n\n这表示身份验证存在问题。 尝试清除本地存储和 Cookie，然后重试。\n\n如果仍然无法连接并且看到的消息未在此列表中，请检查 Codespaces 的服务可用性[](https://www.githubstatus.com/)。\nCodespaces如果服务可用，则可能需要联系支持人员。 有关详细信息，请参阅“[与 GitHub Codespaces 支持协作](/zh/codespaces/troubleshooting/working-with-support-for-github-codespaces)”。\n\n## 无法连接到 JupyterLab 中的代码空间\n\n要在 JupyterLab 中使用 codespace，必须确保 codespace 已安装 JupyterLab。\nGitHub Codespaces 使用的默认开发容器映像包含 JupyterLab，但如果你已自定义开发容器配置，则必须手动安装 JupyterLab。\n\n如果 codespace 使用基于 Debian 的映像，则可以将 `python` 功能添加到 `devcontainer.json` 文件，并将 `installJupyterlab` 选项设置为 `true`，从而在开发容器中安装 JupyterLab。 否则，请直接将其安装在 Dockerfile 中。 有关安装说明，请参阅 JupyterLab 文档中的[安装](https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html)。\n\n有关 `python` 功能的详细信息，请参阅[`devcontainers/features` 存储库](https://github.com/devcontainers/features/tree/main/src/python)中的自述文件页。 有关 `devcontainer.json` 文件和 Dockerfile 的详细信息，请参阅 [开发容器简介](/zh/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers#devcontainerjson)。\n\n如果仍然无法连接， 可能需要联系支持人员。 有关详细信息，请参阅“[与 GitHub Codespaces 支持协作](/zh/codespaces/troubleshooting/working-with-support-for-github-codespaces)”。\n\n## 用于 GitHub Codespaces 的 Visual Studio Code 扩展无法连接\n\n如果无法从 Visual Studio Code 桌面连接到 codespace，请使用以下故障排除步骤。\n\n1. 检查是否已安装最新版本的 GitHub Codespaces 扩展。 该扩展是预览版，并且频繁发布更新。\n   1. 在 Visual Studio Code中，显示“扩展”选项卡。\n   2. 选择扩展 GitHub Codespaces 以显示扩展的概述页。\n   3. 如果有可用更新，则会显示一个按钮，单击“更新到 X.X.X”以升级到最新版本。\n2. 检查你当前使用的是 Visual Studio Code 的稳定版，还是 [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/) 版本（夜间更新）。 如果使用的是内部版本，请尝试安装[稳定版本](https://code.visualstudio.com/)。\n3. 确保公司网络没有阻止连接。\n   1. 如果收到错误（如 `connect EACCES`、`connect ECONNREFUSED`、`getaddrinfo ENOTFOUND` 或其他类似错误），则防火墙可能会阻止与连接服务的连接。 若要验证这一点，请访问[此 URL](https://global.rel.tunnels.api.visualstudio.com/api/version)。 如果请求失败或未看到任何数据，则可能需要与系统管理员协作，将 `*.visualstudio.com` 添加到防火墙的 IP 允许列表。\n   2. 如果看到错误 `Tunnel service HTTPS certificate is invalid. This may be caused by the use of a self-signed certificate or a firewall intercepting the connection` ，则可能是防火墙正在执行 TLS 检查并注入无法验证的自签名证书 GitHub 。 若要解决此问题，系统管理员需要允许 `*.visualstudio.com` 绕过检查，或者安装防火墙在本地计算机上注入的根 CA。\n\n如果仍然无法连接， 可能需要联系支持人员。 有关详细信息，请参阅“[与 GitHub Codespaces 支持协作](/zh/codespaces/troubleshooting/working-with-support-for-github-codespaces)”。\n\n### 代码空间存在延迟问题\n\n如果代码空间看起来特别慢或存在延迟问题，则可能是在远离您的区域中创建的。 若要解决此问题，可以 [手动设置 GitHub Codespaces 区域](/zh/codespaces/setting-your-user-preferences/setting-your-default-region-for-github-codespaces)。"}