A Raspberry Pi Minecraft server is a cost-effective way to have your very own private server with your friends or just for stuffing around on.
I have had mine running for quite some time now and haven’t come across too many problems. It is very important to know that this server will not be able to hold many people.
From my experience, anything over five people and the server will start to get a bit wonky. I found the optimal amount of people is only two to three, but this can be improved upon by tweaking the server.
We are also going to be using the spigot version of Minecraft as the default install didn’t work for me. I found that it will crash a lot, be laggy, and is very unstable. The official Java version may improve over time.
If you are looking for the Bedrock server, be sure to check out our Minecraft Bedrock server tutorial. It will take you through all the steps to setting it up correctly.
In this project, we will utilize Java, which should already be installed on Raspberry Pi OS. We will make a few changes to optimize the server for the Raspberry Pi 2, 3, 4, or 5. We will also set it up so you can access it on the web, and have it reboot if the Pi goes offline for any reason.
Equipment
Please find the equipment that I used for making this Raspberry Pi Minecraft server below.
Recommended
- Raspberry Pi ( Amazon | SunFounder )
- Micro SD Card ( Amazon | SunFounder )
- Ethernet Cable ( Amazon ) or Wi-Fi ( Amazon | SunFounder ) (I recommend using an ethernet for the best network performance)
- Power Supply ( Amazon | SunFounder )
- USB Keyboard ( Amazon | SunFounder )
- USB Mouse ( Amazon | SunFounder )
Optional
- HDMI Cable ( Amazon | SunFounder )
- Raspberry Pi Case ( Amazon | SunFounder )
Video Tutorial
If you want to see how to set up the server, then check out my video below. Otherwise, I have a detailed text explanation immediately below the video.
If you like the video, please make sure you subscribe or follow us on social media, so you are kept up to date.
Setting up the Raspberry Pi Minecraft Server
Firstly, we must install an operating system onto the Raspberry Pi. If you haven’t already done this, check out our awesome guide on installing Raspberry Pi OS. It will take you through all the steps that you will need to do.
In this tutorial, we will work entirely in the terminal. It is probably best we boot straight into the terminal so we can save on resources by not loading the GUI.
1. First, update operating system packages to the latest version by entering the following commands.
sudo apt update
sudo apt upgrade
2. Now, we will need to make a couple of changes in the config tool. Let’s bring the tool up by entering the following line.
sudo raspi-config
If you need more information regarding the raspi-config tool, please check out our guide.
3. Also, it is unlikely you want to boot into the desktop, so ensure the boot option is set to the CLI (Command Line Interface). This change will help give the server as much processing power as possible.
To change the boot option, select 1 System Options, and select Boot / Auto Login.
Select Console or Console Autologin.
4. Finally, enable SSH so we can access the Pi remotely if required, unless you already have it enabled.
To enable SSH, go to Interface Options. Next, Select I1 SSH. Lastly, answer <YES> to enable the SSH server.
5. Now go to <Finish> on the main screen and answer <YES> to the reboot question.
6. We will now want the IP address of our Pi for when we try to connect to our server. To get the Raspberry Pi IP address, enter the hostname command.
sudo hostname -I
To ensure the IP doesn’t change, you should set up setup a static IP address on the Raspberry Pi and your router.
7. Next, we need to make sure that Git and jq is installed. Otherwise, we will not be able to build the server.
Enter the following command to install the Git software as well as jq. jq allows us to easily interpret JSON data within the terminal.
sudo apt install git jq
8. By default, Java (17) should already be available on Raspberry Pi OS (Bookworm). However, if you wish to use the latest version of the Minecraft server, you will need to use a newer version than what is available.
To install a version of Java compatible with Minecraft 1.20.6 + (Java 21 or 22), please follow our installing Java guide.
9. Now, we will need the Minecraft server file, which we will create using a builder tool that Spigot supplies.
To get the tools, enter the following commands.
mkdir ~/minecraft
cd ~/minecraft
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
10. Now we will want to run the build tools file, so it creates our Spigot server. It will take about 15 minutes to finish.
Change --rev latest
at the end of the command to get a different version. Don’t forget to change latest in the command to the version number you wish to download. For example, --rev 1.20.6
will download version 1.20.6.
java -Xmx1024M -jar BuildTools.jar --final-name server.jar --rev latest
Important: If you have a Raspberry Pi B+, B, or any variation before the Raspberry Pi 2, the build tools will likely fail. You will need to generate the spigot.jar on a more powerful computer instead.
11. To ensure the Spigot server successfully downloaded and saved, simply type ls
. You should see spigot-1.20.6.jar
. The filename may be different depending on the version you downloaded.
ls
Make sure you remain in the ~/minecraft
folder as we want all the server files to be created in here. If you start the server in a different folder, it will create the files there.
12. Now we are ready to launch the server. To do this, enter the following command. You may need to change the version number depending on what version you’re using e.g. spigot-1.20.6.jar
.
Raspberry Pi 1
java -Xms256M -Xmx496M -jar ~/minecraft/server.jar nogui
Raspberry Pi 2, 3, 4, or 5
java -Xms512M -Xmx1008M -jar ~/minecraft/server.jar nogui
With the 2GB and 4GB variants of the Raspberry Pi 4 or 5, you can increase the Xmx value even higher.
The server will stop straight away as we will need to agree to the Eula. You can do this by opening the Eula by typing the following command.
nano eula.txt
13. In here, change “false
” to “TRUE
“. Once done, save and exit by pressing CTRL + X, then Y.
14. Now relaunch the server. It will take a while to create a map, so give it about three to five minutes. If you ever reboot again, it will only take thirty seconds to load if the map has already been created.
15. The server should be running and accessible over the local network.
16. You might want to mod your user now so that you can use all the server commands when you log in. If we have it auto-boot on startup, accessing the server backend is slightly more difficult.
To mod your user, simply run the following command when the server has launched (Replacing username with your username).
op username
17. The Minecraft server on the Raspberry Pi will now be up and running fine, but you may want to do some optimizations to the server to make it run even better.
Connecting to the Minecraft Server
If you are on a local network, it should be pretty easy to connect to the Minecraft server running on the Raspberry Pi. To test it out, follow the steps below.
1. Load the Minecraft Java client on a computer within the same local network as the Pi. Ensure the version of the client matches the version of the server.
2. Go to multiplayer, and your server might appear in the local list. If it doesn’t, simply go to direct connect and enter the IP address we got earlier on the Pi using the hostname command.
hostname -I
3. If you want to allow access to the Minecraft server via the internet, you will need to set up port forwarding.
Assuming you want to learn how to do this, head over to my guide on setting up Raspberry Pi port forwarding. You will need to port forward the port 25565 (unless you change it in the server properties) to the IP of your Pi.
Configuring the Server
Here are a few tips for configuring the server and getting it up and running.
Optimizing the Minecraft Server
To get the most out of our Minecraft server on the Raspberry Pi, you can install a plugin to help optimize the performance.
There are many plugins that can help with performance or extend the server’s functionality. Simply use the wget command to download them to the Pi. Below is an example.
cd ~/minecraft/plugins
wget -O example.jar <example_plugin_url>
Editing the Minecraft Properties
You will probably want to know how to edit the server properties. This ability to edit is very important for optimizing the server and customizing it to how you want the server to be.
If you want more information for each of the server settings, you can find a good page on all the server properties here.
To enter the server properties, enter the following line.
sudo nano ~/minecraft/server.properties
Now, we will want to change a few settings to help optimize the performance of the server.
You can change these and other settings to whatever you like however you want, but keep in mind the Pi can’t handle too much processing.
view-distance=04
max-player=5
Boot on Startup
To have the server start on boot, we will need to do a few extra steps.
1. We will need to create a service for the Minecraft server so let’s start writing the service file by entering the command below.
sudo nano /lib/systemd/system/minecraftserver.service
2. In this file you will need to enter the following text.
This file defines the service, so the service manager knows how and what to run. Don’t forget to update the spigot version number whenever you upgrade.
Update “<USER>
” with the username you plan on using to run the server. You can see the username of your user by entering the whoami command into the terminal.
[Unit]
Description=Minecraft Spigot Server
[Service]
User=<USER>
Group=<USER>
Restart=on-abort
WorkingDirectory=/home/<USER>/minecraft/
ExecStart=/usr/bin/java -Xms512M -Xmx1008M -jar /home/<USER>/minecraft/server.jar nogui
[Install]
WantedBy=multi-user.target
Once done, save the file by pressing CTRL + X then Y followed by ENTER.
3. Now, we will need to enable the service. You can enable the service by running the command below.
sudo systemctl enable minecraftserver.service
4. You should now be able to start the Minecraft server by simply using the following command.
sudo systemctl start minecraftserver.service
5. Using a similar command, you can check on the status of the service. Checking the status is great for debugging.
sudo systemctl status minecraftserver.service
5. You can stop the server by using the following command.
sudo systemctl stop minecraftserver.service
Your server should now start on boot. You can test it by restarting the Raspberry Pi. It will take a few minutes to startup.
sudo reboot
If you want to get access to the server on the command line, then you will need to shut down the server and load it using the normal command.
Updating your Minecraft Server on the Raspberry Pi
In this section, we will be showing you how to update to the latest version of the Minecraft server on your Raspberry Pi.
1. Before we can begin to update the Minecraft server, we will need to change to the directory where the server is stored.
If you have followed our tutorial, this means you should be able to change to the correct place by running the command below.
cd ~/minecraft/
2. The first thing we will want to do now that we are in the right place is ensure we have the latest version of the Spigot build tools.
We can use the wget command to download the latest release by using the following in the terminal.
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
3. With the build tools updated, we can now grab the version number for the latest version of the Minecraft server by using the following command.
If you have a particular version of the Minecraft server, you want to use on your Raspberry Pi replace the command with that here. Otherwise, we can use a bit of curl and jq magic to get the version number we are after.
MINECRAFT_VERSION=$(curl -sS https://launchermeta.mojang.com/mc/game/version_manifest.json | jq -r '{latest: .latest.release} | .[]')
4. Once you have got your version number saved to the environment variable we can proceed.
Before we can update the Minecraft server on our Raspberry Pi, we will need to stop the current one from running. You can stop the running server by running the command below.
sudo systemctl stop minecraftserver
5. Now use the Spigot build tools to download and update you Minecraft server to the latest version.
Please note that this process can take a couple of minutes to complete.
java -Xmx1024M -jar BuildTools.jar --final-name server.jar --rev $MINECRAFT_VERSION
6. Once the update process completes, you can start the server up by using the following command.
sudo systemctl start minecraftserver
Conclusion
I hope this tutorial has helped you in setting up a stable version of a Raspberry Pi Minecraft server. If you like this tutorial, then be sure to check out our many other Raspberry Pi Projects.
Also, feel free to drop us a comment below if you have better optimization settings, plugins, or ideas. If you’re having trouble, let us know below.
Hi, I got a question from the kids: when the server is 1.20.6 does the client for Minecraft on their pc also have to be version 1.20.6 and not the newest version 1.21.1?
One of them also told me that he hopes this perscription will be updated with information on how to update when new versions of the Minecraft Java sercer comes along.
Thank you, Bjorn
Hi Bjorn,
The client and the server versions will need to match in the vast majority of cases. Sometimes Minecraft releases a hotfix for the server that doesn’t require a client update, but this isn’t super common.
I have added a new section that covers how you can update to the latest version of the Minecraft server on your Raspberry Pi.
Please note that you will need to make some changes as I have adjusted how some things work to make updating a simpler process.
1. First you will need to install the “jq” package by using the command below.
2. Next, you will want to stop the current Minecraft server as we need to adjust the “execstart” line.
3. Now edit the systemd file.
4. Now change the line so that the “
.jar
” file is just called “server.jar
“.5. Once you have made this change, save and quit by pressing CTRL + X, Y, and then ENTER.
6. Now follow our guide on updating to the latest version of the Minecraft server.
Please let me know if all these steps worked for you. I try to avoid making key changes to how the tutorial works but I thought these changes should improve things in the long run as we won’t have to constantly change the name of the server jar file.
Kind regards,
Emmet
Thank you!
Using RPI 5 8GB for a Spigot Java Minecarft server only, would, to benefit from more memory, something like this make sense?
java -Xms1G -Xmx7G -jar ~/minecraft/spigot-1.20.6.jar nogui
Hi Bjorn,
That should work fine for allocating more memory.
Hi,
up to 10 children will use the minecraft server running on a RPI 5 with 8 gb.
They builds and makes different construktions.
How can I include in automatic startup for the RPI to “restart” the same actual server without loosing what they have built?
Hi Bjorn,
I’m not entirely certain what you are asking here but I will do my best to answer.
Every time you start the Minecraft server it should automatically continue from the last save of your Minecraft world. The world is typically saved every 5 minutes automatically unless you have changed that setting.
Of course, if your Pi happened to lose power between those 5 minutes you will lose anything done in that time. The only real solution to that is to attach something like a UPS to give you more time to safely stop the server.
Please let me know if that answers your question.
Kind Regards,
Emmet
Thank you Emmet.
Your answer gave me the info I needed.
Hi, is there a tutorial to setup a bedrock server on a pi?
Hi Agustin,
We do have a tutorial that covers setting up a bedrock Minecraft server on the Raspberry Pi. We have to rely on a third-party server though called Nukkit.
Cheers,
Emmet
My problem is that the ip is local so I cant run the server to other people. Do you know how to fix this?
Hi Aaron,
First you will need to make sure that you forward the port
25565
on your router to your Raspberry Pi. This will allow outside users to access the Minecraft server.Next you will need to give users your external IP address. Just typing “what is my ip address” in to Google should give you this if you don’t know it already.
If you have a dynamic external IP address and not a static one it might also help to set up a dynamic dns service. Our guide will show you how to do this, basically the service updates a domain name with your IP address whenever it is changed.
Cheers,
Emmet
How do i get it to bind to the port on my pi? i have it loaded but when i do a port scan on the pi the port is not open. I loaded it with plugins and loads up just unable to access it since the port is not open.
Hi Chris,
When the Minecraft server starts up it will automatically bind itself to the port, otherwise, you will see an error message appear in the command line.
If you are trying to connect outside of your home network, you will need to port forward 25565. The software is unable to automatically do this for you.
Cheers,
Emmet
Hey Gus, I’m just reporting this issue that may propagate. The issue is my Raspberry Pi ran out of memory when using this: java -Xmx1024M -jar BuildTools.jar
But I changed the Xmx1024M argument to Xmx512M. So it’s now java -Xmx512M -jar BuildTools.jar and it worked!