Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Visit the Heroku Blog

    Find news and updates from Heroku in the blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Model Context Protocol
    • Vector Database
    • Working with AI
    • Heroku Inference
      • Quick Start Guides
      • Inference API
      • Inference Essentials
      • AI Models
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Language Support
  • Java
  • Working with Java
  • Setting the HTTP Port for Java Applications

Setting the HTTP Port for Java Applications

English — 日本語に切り替える

Last updated December 09, 2024

Table of Contents

  • Spring Boot
  • Webapp Runner (Tomcat)
  • Play Framework
  • Dropwizard
  • Thorntail
  • Ratpack
  • Grails

Heroku expects a web application to bind its HTTP server to the port defined by the $PORT environment variable. Many frameworks default to port 8080, but can be configured to use an environment variable instead. In most cases, the port can be configured by adding a parameter to the java command in an application’s Procfile, but some frameworks provide a configuration file. The most common Java frameworks are listed here.

Spring Boot

Spring-Boot provides a few different mechanisms for setting the HTTP port. It can be passed an option to the executable JAR file (i.e. the options after the -jar app.jar options in your java command):

--server.port=$PORT

Or as a Java system property:

-Dserver.port=$PORT

In both cases, these options can be added to the java command in an app’s Procfile. Another option is a configuration element in the application.yml:

server:
    port: $PORT

For more info see Spring Boot documentation on Properties and Configuration

Webapp Runner (Tomcat)

Webapp Runner allows you to launch an exploded or compressed war on your filesystem into a Tomcat container with a simple java -jar command. It accepts the following option to the executable JAR file (i.e. the options after the -jar webapp-runner.jar options in your java command):

--port $PORT

When using the heroku war:deploy and Heroku Maven Plugin tools, this option is configured for you. For more information, see the Webapp Runner documentation.

Play Framework

The Play Framework, which uses Netty as its server, accepts a Java system property (i.e. an option to the java command):

-Dhttp.port=$PORT

For more info see the Play documentation for Heroku.

Dropwizard

The Dropwizard framework accepts a Java system property:

-Ddw.server.applicationConnectors[0].port=$PORT

For more information see the Dropwizard Configuration reference.

Thorntail

The Thorntail framework accepts a system property:

-Dswarm.http.port=$PORT

For more information see the WildFly Swarm documentation.

Ratpack

The Ratpack framework, which uses the Netty server, automatically detects the $PORT environment variable and configures the app to use it.

Grails

The Grails 3 framework produces a WAR file that can be run with either Tomcat or Jetty. See the Webapp Runner section for more information.

For more information see the WildFly Swarm

Keep reading

  • Working with Java

Feedback

Log in to submit feedback.

Warming Up a Java Process Warming Up a Java Process

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices