Fix my Minecraft Server after trying to update server.properties?

I followed the instructions here when trying to update the difficulty setting on my server. I even created a backup of the config before doing anything.

I only changed the difficulty line on the file, but after rebooting the server, all I get on trying to log into the game is: Failed to connect to the server - Connection refused no further information.

I then went to restore the backup file and received the same error. At this point I realized that I did all of this from the root login as opposed to the user that created the system. I have attempted to correct the ownership/group of the files I touched but am not having any luck.

Any ideas?

1 Reply

I attempted to recreate your issue by deploying a minecraft server following the same steps that you indicated and then edited the ~/minecraft/server.properties file as you did. For the sake of transparency, I’m not a Minecraft player, and I’m not intimately familiar with the inner workings of Minecraft.

What I saw was that when I stopped the mcserver.service either as a limited or sudo user and then restart the service as a limited or sudo user, the service failed to start.

Rebooting the server seemed to fix that. I suspected that there are other services/dependencies tied to mcserver.service that must be run as the root user that aren’t being seen here or require a reboot for one reason or another.

In an attempt to recreate the issue further I next copied the ~/serverfiles/server.properties file to ~/serverfiles/server.properties.bak, deleted the server.properties, and then copied server.properties.bak back to the original name with: cp server.properties.bak server.properties which caused both files to now have root:root user/group ownership.

When changing the server.properties file, it’s really important to check the ownership of the file after and make sure they are both owned by the same user/group as the limited user created for the instance. It sounds like you tried to do this as well, but quite honestly, I ran into some of the same unexpected issues that you did. I changed ownership of the file (while logged in as root) using:

sudo chown $user:$user server.properties

$user should be your limited user’s name in this example.

I got confirmation of the issue by viewing systemctl status mcserver.service which gave the following output:

Mar 22 20:17:48 143-42-138-85.ip.linodeusercontent.com systemd[1]: Starting mcserver...
Mar 22 20:17:50 143-42-138-85.ip.linodeusercontent.com bash[647]: [54B blob data]
Mar 22 20:17:50 143-42-138-85.ip.linodeusercontent.com bash[647]: Information! The current user ($user) does not have ownership of the following files:
Mar 22 20:17:51 143-42-138-85.ip.linodeusercontent.com bash[1562]: User  Group  File
Mar 22 20:17:51 143-42-138-85.ip.linodeusercontent.com bash[1562]: root  root   /home/$user/serverfiles/server.properties.bak
Mar 22 20:17:51 143-42-138-85.ip.linodeusercontent.com bash[647]: Information! please see https://docs.linuxgsm.com/support/faq#fail-starting-game-server-p>
Mar 22 20:17:51 143-42-138-85.ip.linodeusercontent.com systemd[1]: mcserver.service: Control process exited, code=exited, status=1/FAILURE
Mar 22 20:17:51 143-42-138-85.ip.linodeusercontent.com systemd[1]: mcserver.service: Failed with result 'exit-code'.

This caused the server to fail to start and changing the ownership of server.properties alone didn't fix this as the .bak version was also recognized during startup. Deleting the .bak file finally fixed the issue. One last reboot, and everything returned to normal, including the ability for the limited user to stop/start mcserver.service.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct