java.net.BindException: Address already in use

Atlassian JIRA | Lucas Guminski [Atlassian] | 8 years ago
  1. 0

    Hi, I run 2 instances based on the same image (amiId: ami-08dc3b61) and ebs snapshot (snap-13f6037a). I have already did this a few times before, but this time the startup of elastic agent failed with BindException. {noformat} 2009-03-13 06:38:09,564 INFO [main] [ElasticAgentBootstrap] Using tunnnelling. Registering 'httpt' and 'httpst' protocols. 1 [main] INFO com.atlassian.bamboo.agent.elastic.client.ElasticAgentBootstrap - Using tunnnelling. Registering 'httpt' and 'httpst' protocols. 2009-03-13 06:38:11,729 INFO [com.sun.sungrid.service.tunnel.server.TunnelServer] [TunnelServer] Waiting for tunnel connection. 2166 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.service.tunnel.server.TunnelServer - Waiting for tunnel connection. 2009-03-13 06:38:12,136 INFO [com.sun.sungrid.service.tunnel.server.TunnelServer] [TunnelServer] Accepted tunnel connection. 2573 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.service.tunnel.server.TunnelServer - Accepted tunnel connection. 2009-03-13 06:38:12,139 INFO [com.sun.sungrid.service.tunnel.server.TunnelServer] [TunnelServer] Waiting for tunnel connection. 2576 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.service.tunnel.server.TunnelServer - Waiting for tunnel connection. 2009-03-13 06:38:12,214 INFO [com.sun.sungrid.service.tunnel.server.TunnelServer] [TunnelServer] Accepted tunnel connection. 2651 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.service.tunnel.server.TunnelServer - Accepted tunnel connection. 2009-03-13 06:38:12,215 INFO [com.sun.sungrid.service.tunnel.server.TunnelServer] [TunnelServer] Waiting for tunnel connection. 2652 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.service.tunnel.server.TunnelServer - Waiting for tunnel connection. 2009-03-13 06:38:12,571 INFO [pool-1-thread-3] [LocalAcceptor] Waiting for local connection on port 4527. 3008 [pool-1-thread-3] INFO com.sun.sungrid.service.tunnel.server.LocalAcceptor - Waiting for local connection on port 4527. 2009-03-13 06:38:12,677 ERROR [pool-1-thread-2] [TunnelAcceptor] Error while accepting tunnel connections. java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359) at java.net.ServerSocket.bind(ServerSocket.java:319) at java.net.ServerSocket.<init>(ServerSocket.java:185) at java.net.ServerSocket.<init>(ServerSocket.java:97) at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:156) at com.sun.sungrid.service.tunnel.server.TunnelAcceptor.run(TunnelAcceptor.java:93) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) at java.lang.Thread.run(Thread.java:595) 3114 [pool-1-thread-2] ERROR com.sun.sungrid.service.tunnel.server.TunnelAcceptor - Error while accepting tunnel connections. java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359) at java.net.ServerSocket.bind(ServerSocket.java:319) at java.net.ServerSocket.<init>(ServerSocket.java:185) at java.net.ServerSocket.<init>(ServerSocket.java:97) at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:156) at com.sun.sungrid.service.tunnel.server.TunnelAcceptor.run(TunnelAcceptor.java:93) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) at java.lang.Thread.run(Thread.java:595) {noformat} Here is the output of netstat {noformat} # netstat -lnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:1666 0.0.0.0:* LISTEN 1771/p4d tcp 0 0 :::3690 :::* LISTEN 8909/svnserve tcp 0 0 :::4527 :::* LISTEN 1434/java tcp 0 0 :::26224 :::* LISTEN 1434/java tcp 0 0 :::22 :::* LISTEN 883/sshd udp 0 0 0.0.0.0:68 0.0.0.0:* 788/dhclient Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ACC ] STREAM LISTENING 2713 866/dbus-daemon /var/run/dbus/system_bus_socket # ps -ocmd -p 1434 CMD java -server -Xms32m -Xmx512m -XX:MaxPermSize=256m -cp /opt/bamboo-elastic-agent/bin/../lib:/opt/bamboo-elastic-agent/bin/../lib/spring-jdbc-2.0.7.jar:/opt/bamboo-elastic-agent/bin/../lib/webwork-2.2.5.jar:/opt {noformat} Bamboo elastic agent process has 2 sockets open for listening - 4527 and 26224. When I compare it with the second instance where the startup succeeded I can see that there should be a third socket open - 46593. Probably opening of that socket was the problem. But I cannot see nothing that occupies that port. So maybe it was a hazard between 2 threads of the same app? Cheers, Lucas

    Atlassian JIRA | 8 years ago | Lucas Guminski [Atlassian]
    java.net.BindException: Address already in use
  2. 0

    Hi, I run 2 instances based on the same image (amiId: ami-08dc3b61) and ebs snapshot (snap-13f6037a). I have already did this a few times before, but this time the startup of elastic agent failed with BindException. {noformat} 2009-03-13 06:38:09,564 INFO [main] [ElasticAgentBootstrap] Using tunnnelling. Registering 'httpt' and 'httpst' protocols. 1 [main] INFO com.atlassian.bamboo.agent.elastic.client.ElasticAgentBootstrap - Using tunnnelling. Registering 'httpt' and 'httpst' protocols. 2009-03-13 06:38:11,729 INFO [com.sun.sungrid.service.tunnel.server.TunnelServer] [TunnelServer] Waiting for tunnel connection. 2166 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.service.tunnel.server.TunnelServer - Waiting for tunnel connection. 2009-03-13 06:38:12,136 INFO [com.sun.sungrid.service.tunnel.server.TunnelServer] [TunnelServer] Accepted tunnel connection. 2573 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.service.tunnel.server.TunnelServer - Accepted tunnel connection. 2009-03-13 06:38:12,139 INFO [com.sun.sungrid.service.tunnel.server.TunnelServer] [TunnelServer] Waiting for tunnel connection. 2576 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.service.tunnel.server.TunnelServer - Waiting for tunnel connection. 2009-03-13 06:38:12,214 INFO [com.sun.sungrid.service.tunnel.server.TunnelServer] [TunnelServer] Accepted tunnel connection. 2651 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.service.tunnel.server.TunnelServer - Accepted tunnel connection. 2009-03-13 06:38:12,215 INFO [com.sun.sungrid.service.tunnel.server.TunnelServer] [TunnelServer] Waiting for tunnel connection. 2652 [com.sun.sungrid.service.tunnel.server.TunnelServer] INFO com.sun.sungrid.service.tunnel.server.TunnelServer - Waiting for tunnel connection. 2009-03-13 06:38:12,571 INFO [pool-1-thread-3] [LocalAcceptor] Waiting for local connection on port 4527. 3008 [pool-1-thread-3] INFO com.sun.sungrid.service.tunnel.server.LocalAcceptor - Waiting for local connection on port 4527. 2009-03-13 06:38:12,677 ERROR [pool-1-thread-2] [TunnelAcceptor] Error while accepting tunnel connections. java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359) at java.net.ServerSocket.bind(ServerSocket.java:319) at java.net.ServerSocket.<init>(ServerSocket.java:185) at java.net.ServerSocket.<init>(ServerSocket.java:97) at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:156) at com.sun.sungrid.service.tunnel.server.TunnelAcceptor.run(TunnelAcceptor.java:93) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) at java.lang.Thread.run(Thread.java:595) 3114 [pool-1-thread-2] ERROR com.sun.sungrid.service.tunnel.server.TunnelAcceptor - Error while accepting tunnel connections. java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359) at java.net.ServerSocket.bind(ServerSocket.java:319) at java.net.ServerSocket.<init>(ServerSocket.java:185) at java.net.ServerSocket.<init>(ServerSocket.java:97) at javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:156) at com.sun.sungrid.service.tunnel.server.TunnelAcceptor.run(TunnelAcceptor.java:93) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) at java.lang.Thread.run(Thread.java:595) {noformat} Here is the output of netstat {noformat} # netstat -lnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:1666 0.0.0.0:* LISTEN 1771/p4d tcp 0 0 :::3690 :::* LISTEN 8909/svnserve tcp 0 0 :::4527 :::* LISTEN 1434/java tcp 0 0 :::26224 :::* LISTEN 1434/java tcp 0 0 :::22 :::* LISTEN 883/sshd udp 0 0 0.0.0.0:68 0.0.0.0:* 788/dhclient Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ACC ] STREAM LISTENING 2713 866/dbus-daemon /var/run/dbus/system_bus_socket # ps -ocmd -p 1434 CMD java -server -Xms32m -Xmx512m -XX:MaxPermSize=256m -cp /opt/bamboo-elastic-agent/bin/../lib:/opt/bamboo-elastic-agent/bin/../lib/spring-jdbc-2.0.7.jar:/opt/bamboo-elastic-agent/bin/../lib/webwork-2.2.5.jar:/opt {noformat} Bamboo elastic agent process has 2 sockets open for listening - 4527 and 26224. When I compare it with the second instance where the startup succeeded I can see that there should be a third socket open - 46593. Probably opening of that socket was the problem. But I cannot see nothing that occupies that port. So maybe it was a hazard between 2 threads of the same app? Cheers, Lucas

    Atlassian JIRA | 8 years ago | Lucas Guminski [Atlassian]
    java.net.BindException: Address already in use
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    blmigration_mgr start up error | BMC Communities

    bmc.com | 2 years ago
    java.net.BindException: Address already in use

  1. mauritius 3 times, last 7 months ago
1 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.net.BindException

    Address already in use

    at java.net.PlainSocketImpl.socketBind()
  2. Java RT
    DefaultServerSocketFactory.createServerSocket
    1. java.net.PlainSocketImpl.socketBind(Native Method)
    2. java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
    3. java.net.ServerSocket.bind(ServerSocket.java:319)
    4. java.net.ServerSocket.<init>(ServerSocket.java:185)
    5. java.net.ServerSocket.<init>(ServerSocket.java:97)
    6. javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:156)
    6 frames
  3. com.sun.sungrid
    TunnelAcceptor.run
    1. com.sun.sungrid.service.tunnel.server.TunnelAcceptor.run(TunnelAcceptor.java:93)
    1 frame
  4. Java RT
    Thread.run
    1. java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    3. java.lang.Thread.run(Thread.java:595)
    3 frames