Main Tutorials

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

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
badcoder
4 years ago

thank you sir

nickyrabit
5 years ago

nice solution