You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法向Heroku的main分支推送代码 提示502错误该如何解决?

Heroku git推送返回502错误解决方案

你遇到的报错如下:

git push heroku main fatal: unable to access 'https://projectname.herokuapp.com/': The requested URL returned error: 502

可按照以下步骤依次排查解决:

  • 首先确认远程仓库地址配置是否正确
    Heroku的Git推送地址不是应用的访问地址(后缀为herokuapp.com),正确的HTTPS推送地址格式为https://git.heroku.com/<你的应用名称>.git
    执行git remote -v查看当前heroku对应的远程地址,若配置错误,执行以下命令修改:
    git remote set-url heroku https://git.heroku.com/<你的应用名称>.git
    
  • 排查本地网络配置问题
    检查是否开启了代理工具导致请求异常,可先临时清除Git的代理配置后重试:
    git config --global --unset http.proxy
    git config --global --unset https.proxy
    
  • 更换推送协议
    如果HTTPS方式持续报错,可切换为SSH协议推送:
    1. 先将本地SSH公钥添加至你的Heroku账号设置中
    2. 执行命令修改远程仓库地址为SSH格式:
    git remote set-url heroku git@heroku.com:<你的应用名称>.git
    
  • 确认Heroku服务状态
    偶尔Heroku的Git服务会出现临时故障,可等待10-30分钟后再次尝试推送。

内容的提问来源于stack exchange,提问作者RAA

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.23 19:54:00