spring-projects / spring-projects/spring-boot

Embedded web servers behave inconsistently when server.port is set to -1

Open
#17,073 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: pending-design-work type: task
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

The behaviour is as follows when starting with server.port=-1:

  • Jetty: app starts and stays running, but is not listening for HTTP connections
  • Netty: app fails to start as -1 is an illegal port number
  • Tomcat: app starts and stays running, but is not listening for HTTP connections
  • Undertow: app starts and then stops

Further to the above, the way that autoStart is implemented at the moment is a little odd. When a web server is created with autoStart set to false, calling start() on that server will then have no effect and there's no way to set autoStart back to true so that the web server can be started. In other words, it's not really disabling automatic start, but disabling start altogether.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the embedded server startup paths for Jetty, Netty, Tomcat, and Undertow when server.port=-1, then inspect how autoStart controls the server lifecycle. Done means the port behavior is consistent across servers and a server created with autoStart=false can still be started explicitly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.