Score:0

Application cannot start, claiming "port is already in use", but it is not

ru flag

Application (apache storm) cannot start throwing the below exception

2022-04-12 04:56:13.997 o.a.s.d.u.UIServer main [ERROR] Exception in UlServer 
java.io.I0Exception: Failed to bind to 0.0.0.0/0.0.0.0:8888 
at org.eclipsejettyserver.ServerConnector.openAcceptChannel(ServerConnectorjava346) ~[jetty-server-9.4.14.v20181114jan9.4.14.v20181114] 
at org.eclipsejetty.server.ServerConnector.open(ServerConnectorjava:308) ~[jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114] 
at org.eclipsejetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnectorjava:80) ~[jetty-server-9.4.14.v20181114jar:9.4.14.v20181114] 
at org.eclipsejetty.server.ServerConnector.doStart(ServerConnectorjava:236) ~[jetty-server-9.4.14.v20181114jar.9.4.14-v20181114] 
at org.eclipsejetty.util.component.AbstractUfeCycle.start(AbstractlifeCyclejava:68) ~[jetty-util-9.4.14.v20181114jan9.4.14.v20181114] 
at org.eclipsejetty.server.Server.doStart(Serverjava:394) ~[jetty-server-9.4.14.v20181114.jar9.4.14.v20181114) 
at org.eclipsejetty.util.component.AbstractLifeCycle.start(AbstractlifeCyclejava:68) ~[jetty-util-9.4.14.v20181114jar.9.4.14.v20181114] 
at org.apache.storm.daemon.ui.U1Server.main(U1Serverjaval 79) [storm-webapp-2.2.0jar:2.2.0] 
Caused by: java.net-BindException: Address already in use 
at sun.nio.ch.Net.bindO(Native Method) ~[?:?] 
at sumnio.ch.Net.bind(Netjava:455) ~[?:?] 
at sun.nio.ch.Netbind(Netjava:447) ~[?:?] 
at sun.nio.chServerSocketChannelImpl.bind(ServerSocketChannellmpljava:227) ~[?:?] 
at sumnio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptorjava:80) ~[?:?] 
at org.eclipsejetty.server.ServerConnector.openAcceptChannel(ServerConnectorjava:342) ~[jetty-server-9.4.14.v20181114jan9.4.14.v20181114] 
... 7 more 

The port is free though, I used multiple tools (telnet, nc, netstat etc) to ensure this. Also the same behaviour was spotted on another server with another app, but JMV-based as well
OS: RHEL 7.9

Java: 11.0.12

in flag
`0.0.0.0/0.0.0.0:8888` is an unusual style for a listener. What exactly have you configured in your application?
Ben Voigt avatar
pl flag
The actual error is "failed to bind", any "port is already in use" message may be a well-meaning-but-wrong troubleshooting suggestion. Privileges/capabilities (such as SELinux uses) can also cause binding failure.
us flag
Were you were able to successfuly listen on port 8888 using `nc`? or did you only try to connect to it?
ae flag
How exactly did you check that the port is "free"? Can you share the commands you run and their output? One possible problem you might be facing is a socket in TIME_WAIT state - see e.g. https://stackoverflow.com/questions/3757289/when-is-tcp-option-so-linger-0-required/13088864#13088864
Score:-1
it flag

Try check TCP and UDP listeners too

netstat -plantu | grep 8888

You can check ports which are opened with lsof too

lsof -i -P -n

Example output

root@machine:~# lsof -i -P -n
COMMAND     PID        USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
memcached   471    memcache   26u  IPv4   18741      0t0  TCP 127.0.0.1:11211 (LISTEN)
vsftpd      511        root    3u  IPv6   18621      0t0  TCP *:21 (LISTEN)
sshd        516        root    3u  IPv4   16971      0t0  TCP *:22 (LISTEN)
sshd        516        root    4u  IPv6   16980      0t0  TCP *:22 (LISTEN)
mysqld      831       mysql   21u  IPv6   20656      0t0  TCP *:33060 (LISTEN)
mysqld      831       mysql   26u  IPv4   17309      0t0  TCP *:3306 (LISTEN)
apache2   32378        root    4u  IPv6 4392606      0t0  TCP *:80 (LISTEN)
apache2   32378        root    6u  IPv6 4392610      0t0  TCP *:443 (LISTEN)
apache2   32396    www-data    4u  IPv6 4392606      0t0  TCP *:80 (LISTEN)
apache2   32396    www-data    6u  IPv6 4392610      0t0  TCP *:443 (LISTEN)
apache2   32397    www-data    4u  IPv6 4392606      0t0  TCP *:80 (LISTEN)
apache2   32397    www-data    6u  IPv6 4392610      0t0  TCP *:443 (LISTEN)
in flag
This does not answer the question, it should be a comment. And the op states that this has already been checked.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.