Why does my Spring Boot app shut down immediately after starting?
Codemia Knowledge Hub ·
A Spring Boot application that starts and then exits straight away, often with no error, usually has nothing keeping it alive: no embedded web server (typically because spring-boot-starter-web is missing), no running non-daemon threads, a bean that fails during startup, or a property such as spring.main.web-application-type=none.
Reasons the app shuts down
1. No web environment
An embedded web server (Tomcat, Jetty or Undertow) or a servlet container is what normally keeps a Spring Boot application running. Without a web environment, Spring Boot runs as a plain Java application: it executes the main method, initializes all beans, and shuts down.
If Spring Boot detects no long-running tasks or web environment, this application closes right after launching.
2. No non-daemon threads
The JVM stays alive only while non-daemon threads are running. If the application only starts daemon threads, or all non-daemon threads finish quickly, the JVM exits. This is the normal behavior for command-line applications that run some logic and stop.
3. ApplicationContext failures
If a bean fails during initialization, for example due to misconfiguration or a missing dependency, the ApplicationContext can stop and the application shuts down.
4. Properties that disable the web server
Setting spring.main.web-application-type=none, directly or indirectly, stops Spring Boot from starting a web server.
Troubleshooting steps
- Check for a web dependency: Make sure
pom.xmlorbuild.gradleincludes Spring Web (spring-boot-starter-web). - Turn on debug logging in
application.propertiesto get more detailed output:
- Review bean configuration: Look in the startup logs for exceptions or errors from beans.
- Inspect
Application.java: Make sure it starts a server or some ongoing service. - Check external configuration: Profiles and environment variables can set properties that make the application shut down.
Causes and fixes at a glance
| Issue | Common Cause | Solution |
| No web environment | Missing web dependencies | Add spring-boot-starter-web |
| No active threads | All threads are daemon threads or complete quickly | Ensure ongoing non-daemon threads |
| ApplicationContext issues | Beans failing during initialization | Fix bean configurations and dependencies |
| Specific configurations | Properties like spring.main.web-application-type=none | Review and adjust application.properties |
Related reading
- Why does spring-boot-3 give javax.servlet.http.HttpServletRequest ClassNotFoundException
- Why does Stream<T> not implement Iterable<T>?
- Why does sun.misc.Unsafe exist, and how can it be used in the real world?
- Why does the default parameterless constructor go away when you create one with parameters
- Why does .NET foreach loop throw NullRefException when collection is null?
- Why does parseInt(1/0, 19) return 18?
- Why does the H2 console in Spring Boot show a blank screen after logging in?
- Why does the MongoDB Java driver use a random number generator in a conditional?
System design interview problems on this topic
- Design an API Rate Limiter: solution and walkthrough
- Design a Distributed Messaging System: solution and walkthrough
- Design an Online Payment Service: solution and walkthrough
- Design a Key Value Store: solution and walkthrough

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.