Mojira Archive
MC-4010

Unable to stop server when it fails to bind port

Sometimes I have few servers running on my PC (which are played on via LAN). Today I was purging my HDD and deleting old servers (I have many directories with servers and their configs and maps). Many of them had port 25565 (the default one) set in server.properties file. And I had already one server running on that port (and there were 3 players there so I couldn't stop it). So several times I got the FAILED TO BIND PORT message. Then every time I wrote "stop" in the terminal with the screen attached under which the server was running. And no time I succeeded. The server is unable to stop itself after getting command "stop" when it's unable to bind port. But when is receives SIGTERM signal, it terminates correctly. Here is the server log:

2012-11-30 19:01:44 \[INFO\] Starting minecraft server version 1.4.4
2012-11-30 19:01:44 \[INFO\] Loading properties
2012-11-30 19:01:44 \[INFO\] Default game type: SURVIVAL
2012-11-30 19:01:44 \[INFO\] Generating keypair
2012-11-30 19:01:45 \[INFO\] Starting Minecraft server on *:25565
2012-11-30 19:01:45 \[WARNING\] **** FAILED TO BIND TO PORT!
2012-11-30 19:01:45 \[WARNING\] The exception was: java.net.BindException: Adresa je užívána
2012-11-30 19:01:45 \[WARNING\] Perhaps a server is already running on that port?
2012-11-30 19:01:48 \[INFO\] An unknown error occurred while attempting to perform this command
2012-11-30 19:01:49 \[INFO\] An unknown error occurred while attempting to perform this command
2012-11-30 19:01:50 \[INFO\] An unknown error occurred while attempting to perform this command
2012-11-30 19:01:51 \[INFO\] An unknown error occurred while attempting to perform this command
2012-11-30 19:01:52 \[INFO\] An unknown error occurred while attempting to perform this command
2012-11-30 19:01:52 \[INFO\] An unknown error occurred while attempting to perform this command
2012-11-30 19:01:53 \[INFO\] An unknown error occurred while attempting to perform this command
2012-11-30 19:01:53 \[INFO\] An unknown error occurred while attempting to perform this command
2012-11-30 19:01:54 \[INFO\] An unknown error occurred while attempting to perform this command
2012-11-30 19:02:06 \[INFO\] Stopping server
2012-11-30 19:02:06 \[INFO\] Saving worlds

There you can see that I started the server, then it failed to bind port and I was writing stop, which didn't do anything. Then, in 19:02:06 I opened htop and terminated it via signal.

I was angry and repeating the command, as you can see. It's not pleasure when this happens many times to me. I had to detach screen every time and start htop, then terminate the server and exit htop. If the bug was fixed I would only have to just write "stop" when this happens. Please, fix this issue. I hope it doesn't depend on some server core mechanics, and it is only one forgotten if() to check something's status or something.