mojira.dev
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.

Linked issues

Attachments

Comments 8

If it failed to bind port, just use the close button on the top right corner on Windows and Linux or top left for Mac, as the error occurs because the server is not really running when it fails to bind it.

No. I was using `screen` so as to be able to close the terminal window without terminating server. You can see http://linux.die.net/man/1/screen for more information. If I clicked the close button, the screen would just detach from the terminal and both, the screen and the server, would run farther, in the background.

I don't think this issue can be closed just because it has solution in some situations like when you use Minecraft_Server.exe or when you execute the server directly in a terminal.

You're saying the server is not really running, so it cannot stop. So just one condition to check if the server is running when typing "stop" command would be enough. It could function like now if the server is running and just send SIGTERM to itself when it isn't running. Simple, not opressing workaround.

Reopening, still an issue.

[17:04:17] [Server thread/INFO]: Starting minecraft server version 13w42a
[17:04:17] [Server thread/INFO]: Loading properties
[17:04:17] [Server thread/INFO]: Default game type: SURVIVAL
[17:04:17] [Server thread/INFO]: Generating keypair
[17:04:17] [Server thread/INFO]: Starting Minecraft server on *:25565
[17:04:17] [Server thread/WARN]: **** FAILED TO BIND TO PORT!
[17:04:17] [Server thread/WARN]: The exception was: java.net.BindException: Address already in use
[17:04:17] [Server thread/WARN]: Perhaps a server is already running on that port?
stop
[17:04:19] [Server thread/INFO]: An unknown error occurred while attempting to perform this command
[17:04:19] [Server thread/ERROR]: Couldn't process command
java.lang.NullPointerException
	at bk.a(SourceFile:84) ~[minecraft_server.13w42a.jar:?]
	at y.a(SourceFile:338) ~[minecraft_server.13w42a.jar:?]
	at y.a(SourceFile:333) ~[minecraft_server.13w42a.jar:?]
	at br.b(SourceFile:19) ~[minecraft_server.13w42a.jar:?]
	at z.a(SourceFile:58) [minecraft_server.13w42a.jar:?]
	at li.av(SourceFile:292) [minecraft_server.13w42a.jar:?]
	at li.a(SourceFile:222) [minecraft_server.13w42a.jar:?]
	at net.minecraft.server.MinecraftServer.run(SourceFile:366) [minecraft_server.13w42a.jar:?]
	at kx.run(SourceFile:617) [minecraft_server.13w42a.jar:?]
Ezekiels-Mac:~ ezekielelin$ /Applications/Server/SnapshotWorld/launch_server.command; exit;
2013-11-26 15:21:56,297 ERROR Unable to rename file /Applications/Server/SnapshotWorld/logs/latest.log to /Applications/Server/SnapshotWorld/logs/2013-10-29-1.log - logs/latest.log (No such file or directory)
[15:21:56] [Server thread/INFO]: Starting minecraft server version 1.7.2
[15:21:56] [Server thread/INFO]: Loading properties
2013-11-26 15:21:56,452 WARN Unable to delete logs/2013-10-29-1.log.
[15:21:56] [Server thread/INFO]: Default game type: SURVIVAL
[15:21:56] [Server thread/INFO]: Generating keypair
[15:21:57] [Server thread/INFO]: Starting Minecraft server on *:25565
[15:21:57] [Server thread/WARN]: **** FAILED TO BIND TO PORT!
[15:21:57] [Server thread/WARN]: The exception was: java.net.BindException: Address already in use
[15:21:57] [Server thread/WARN]: Perhaps a server is already running on that port?
stop
[15:23:01] [Server thread/INFO]: An unknown error occurred while attempting to perform this command
[15:23:01] [Server thread/ERROR]: Couldn't process command
java.lang.NullPointerException
	at bk.a(SourceFile:85) ~[minecraft_server.1.7.2.jar:?]
	at y.a(SourceFile:340) ~[minecraft_server.1.7.2.jar:?]
	at y.a(SourceFile:335) ~[minecraft_server.1.7.2.jar:?]
	at bs.b(SourceFile:19) ~[minecraft_server.1.7.2.jar:?]
	at z.a(SourceFile:58) [minecraft_server.1.7.2.jar:?]
	at lj.aw(SourceFile:298) [minecraft_server.1.7.2.jar:?]
	at lj.a(SourceFile:228) [minecraft_server.1.7.2.jar:?]
	at net.minecraft.server.MinecraftServer.run(SourceFile:366) [minecraft_server.1.7.2.jar:?]
	at ky.run(SourceFile:617) [minecraft_server.1.7.2.jar:?]

Attached latest.log and server.properties.

Confirmed for Minecraft 14w03b.

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases. If this has been done, we can reopen the issue.

Keep in mind that the "Resolved"-Status on this ticket just means "Answered", and that we are waiting for further information on whether this issue still exists or not. We will reopen it as soon as the requested information has been deliviered.

No response for over a year.

Tomáš Varga

(Unassigned)

Confirmed

linux, multiplayer, server

Minecraft 1.4.4, Minecraft 1.4.5, Minecraft 1.6.4, Minecraft 13w42a, Minecraft 1.7.1, ..., Minecraft 14w02c, Minecraft 14w03a, Minecraft 14w03b, Minecraft 14w04a, Minecraft 14w04b

Retrieved