Address already in use: bind

Malien77 months ago

Hi all,
I'm currently trying to set up Traccar on my local machine and have followed the configuration instructions provided on the Traccar website(Build from Source) up to this point: Traccar Build Instructions. Despite following the steps closely, I keep running into a persistent issue when attempting to debug the java program. Here's the error message I receive in my console:

java.net.BindException: Address already in use: bind	
at java.base/sun.nio.ch.Net.bind0(Native Method)
    at java.base/sun.nio.ch.Net.bind(Net.java:555)
    at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337)
    at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294)
    at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:141)
    at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
    at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:600)
    at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:579)
    at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
    at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260)
    at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:380)
    at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:833)

I've checked for any process that might be using the same port and tried different ports, but no luck so far. Here's the command I used for cloning the repo:

git clone --recursive https://github.com/traccar/traccar.git

Any insights or suggestions would be greatly appreciated. Thank you!

jinzo7 months ago

Something is already running on one of the network ports specified in your config. Either for the webserver 8082 default I think? or one of the protocol ones.

Track-trace7 months ago

Did you try, restart your computer and without starting anything check what is already running on that port.

Find the process which is listening on the specific port in Windows with netstat command, just use netstat with find command as shown in below example:

C:\> netstat -ano | find "portnumber"
TCP    0.0.0.0:portnumber           0.0.0.0:0              LISTENING       26732

Last column is PID of process which is listening on port "the port number you want to use” You can verify it by looking into task manager and displaying PID as column.

Find process which is listening on port number in Linux
Great thing is that you can use netstat command in Linux and UNIX as well, though with little difference in option it can show you process listening on a particular port, instead of "-o" I normally use "-p" and then use UNIX grep command to select particular process with PID.

netstat -nap | grep portnumber

How to solve "java.net.BindException: Address already in use"
Now since you have fond out the offending process you can kill that process and restart yours if killing that process is OK, otherwise change the port your server is using and you will not get "java.net.BindException: Address already in use" Exception.

Anton Tananaev7 months ago

Check who's using port 5xxx.