Encountering errors when setting up your Minecraft server can be frustrating, especially on a Raspberry Pi. A common issue users face is the “AccessDeniedException” when trying to run their server jar file. This guide will help you understand why this error occurs and how to resolve it, specifically when setting up a Minecraft server jar, like PaperMC, on your Raspberry Pi.
The error message typically looks like this:
java.nio.file.AccessDeniedException: /home/pi/myssd/papermcservergoede/versions at ...
This error indicates that the Java process does not have the necessary permissions to access or modify certain files or directories. In the context of setting up a Minecraft server jar, this often happens when the server software tries to create directories or extract files but is prevented due to insufficient permissions.
Here are the common causes and solutions to fix the “AccessDeniedException” when running your Minecraft server jar on a Raspberry Pi:
1. Incorrect File Permissions:
The most frequent cause is incorrect file permissions on the server jar file or the directories where the server is trying to unpack or create files. Your user account might not have the write permissions needed in the directory you are trying to run the server from.
Solution: Use the chmod
command to grant execute permissions to the server jar file and write permissions to the server directory.
- Navigate to your server directory in the terminal using the
cd
command. For example:cd /home/pi/myssd/papermcservergoede/
- Grant execute permission to the server jar file:
chmod +x server.jar
(orserver.jar.1
if you are using that name). - Ensure your user has write permissions to the server directory:
chmod -R u+rw .
This command recursively grants read and write permissions to the current user for all files and directories within the current directory.
2. Directory Ownership Issues:
Sometimes, the directory where you are trying to run the server jar might be owned by a different user, preventing your current user from writing to it.
Solution: Use the chown
command to change the ownership of the server directory to your user.
- Identify your username: If you are unsure, type
whoami
in the terminal. - Change ownership of the server directory:
sudo chown -R pi:pi /home/pi/myssd/papermcservergoede/
(Replacepi:pi
with your username:username if different, and adjust the directory path accordingly). This command recursively changes the owner and group of the directory to your user.
3. Running as Sudo (Incorrectly):
While sometimes sudo
is necessary for system-level tasks, running the Minecraft server jar with sudo
might lead to permission issues down the line, especially if the server creates files owned by the root user.
Solution: Avoid running the server jar with sudo
unless absolutely necessary for specific commands. Run the server using your regular user account after correcting file permissions and ownership as described above.
Example Command Sequence:
Assuming your server jar is named server.jar
and located in /home/pi/minecraft_server
, here’s a sequence of commands to troubleshoot permissions:
cd /home/pi/minecraft_server
chmod +x server.jar
chmod -R u+rw .
java -Xmx2048M -Xms2048M -jar server.jar nogui
By addressing these permission and ownership issues, you should be able to resolve the “AccessDeniedException” and successfully launch your Minecraft server jar on your Raspberry Pi. Remember to double-check your directory paths and usernames when using these commands. If you continue to face issues, carefully review the error message for specific file paths and adjust permissions accordingly.