Jetty – java.net.BindException: Address already in use

Start a Java webapp with Maven Jetty plugin.


$ mvn jetty:run

1. Problem

But it hits the following error messages :

[WARNING] FAILED org.eclipse.jetty.maven.plugin.JettyServer@1f53481b:
java.net.BindException: Address already in use
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:433)
	at sun.nio.ch.Net.bind(Net.java:425)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
	at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
	at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
//...

2. Solution

By default, the maven-jetty-plugin start Jetty on port 8080, the above error said the port 8080 is already in use by another application.

To fix it

  1. Find out which program is using port 8080 and kill it. See this Linux – Who is using port 8080
  2. Start Jetty on another port : mvn -Djetty.port=8888 jetty:run

References

  1. Maven Jetty Plugin
  2. Configuring the Jetty Maven Plugin

mkyong

Founder of Mkyong.com, passionate Java and open-source technologies. If you enjoy my tutorials, consider making a donation to these charities.

2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
badcoder
7 years ago

thank you sir

nickyrabit
7 years ago

nice solution