top of page

Deploying Spring Boot applications on Heroku


Heroku is a container-based cloud Platform as a Service (PaaS). Developers use Heroku to deploy, manage, and scale modern apps. It supports several programming languages and has a very simple and convenient deployment model.

Deploying a Spring Boot app on Heroku using Heroku CLI:

Please create Heroku account from Heroku’s Signup Page.

1.Download and install Heroku CLI

The Heroku Command Line Interface (CLI) makes it easy to create and manage your Heroku apps directly from the terminal. It’s an essential part of using Heroku. You can download Heroku CLI from Heroku Dev Center. You’ll also find the instructions for installing Heroku CLI on your platform on that page.

2.Login using your email and password

Enter the following command to login to Heroku using Heroku CLI

                heroku login

You will be prompted to enter your Heroku account’s email and password. Enter all the details -

		Enter your Heroku credentials:
		Password: **************
		Logged in as

3.Create a Heroku app

Create a new heroku app using heroku create command like so -

		heroku create <YOUR_UNIQUE_APP_NAME>

4.Install Heroku Deploy CLI Plugin

Enter the following command in your terminal/Command Prompt to install the heroku-cli-deploy plugin:

		heroku plugins:install heroku-cli-deploy

5.Package your Spring Boot application

Next, you’ll need to package the application in the form of a jar file. You can do that using mvn package command .Execute the following commands from the root directory of the project in Command Prompt.

			mvn clean package

This command will create a packaged jar file of the application in the target folder of the project.

6.Deploy the jar file on Heroku

Deploy the jar file using the following command -

heroku deploy:jar target/projectname.jar --app <APP-NAME>

Please check the log file using below command for verifying the application deployment status.

	heroku logs --tail --app <APP-NAME>

If you get the error like below

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch

We need to change the server.port in the src/main/java/resources/ file like below


The above property will evaluate to the PORT environment variable if it is available, otherwise it will fall back to the default port 8080.

After changing application property, we need to build jar file using mvn clean package and deploy the jar using below command

	heroku deploy:jar target/projectname.jar --app <APP-NAME>

Please verify the log file and check the application status , if it started successfully Please opn the app using heroku open command.

Thanks for reading. In the next article, you’ll learn how to deploy spring boot applications on Heroku app.

709 views0 comments
bottom of page