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

Spring Boot应用部署Heroku遇R10启动超时错误求助

Fixing Heroku R10 Boot Timeout Error for Spring Boot Apps

Hey there, let's get that R10 error sorted out—this is a super common gotcha when deploying Spring Boot apps to Heroku, so I’ve got you covered.

What’s causing this error?

Heroku requires all web processes to bind to the $PORT environment variable it provides when your app starts. By default, Spring Boot uses port 8080, which doesn’t match what Heroku expects. Since your app isn’t binding to the right port within 60 seconds, Heroku kills the process with that SIGTERM signal you see in the logs.

Step-by-step fixes:

  1. Update your Spring Boot port configuration
    Make your app read the $PORT variable so it uses Heroku’s assigned port (and falls back to 8080 for local development):

    • If using application.properties:
      server.port=${PORT:8080}
      
    • If using application.yml:
      server:
        port: ${PORT:8080}
      
  2. Verify your Procfile is set up correctly
    Heroku uses the Procfile to know how to launch your app. Create or update a file named Procfile (capital P, no file extension) in your project root with this line:

    web: java -jar target/your-app-filename.jar
    

    Replace your-app-filename.jar with the actual name of your built JAR file. If you’re using Maven, you can also use web: mvn spring-boot:run, but the JAR approach is more reliable for production deployments.

  3. Re-deploy and check logs
    Commit your changes to Git, then push to Heroku:

    git add .
    git commit -m "Fix Heroku port binding"
    git push heroku main
    

    Use this command to tail the logs and confirm your app binds to the correct port:

    heroku logs --tail
    

Bonus: If you still see timeouts

If your app takes longer than 60 seconds to start, Heroku will still trigger the R10 error. To fix this:

  • Optimize your app’s startup time: use lazy initialization for non-critical beans, reduce unnecessary dependencies, or pre-load resources.
  • Add JVM flags to speed up startup: update your Procfile to include flags like XX:+UseParallelGC:
    web: java -XX:+UseParallelGC -jar target/your-app-filename.jar
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 03:34:53