Raspberry Pi Minecraft Server

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.

Raspberry Pi Minecraft

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.

In this project, we will utilize Java that should already be installed on the Raspberry Pi (If you’re using the full version of Raspbian).

We will make a few changes to optimize the server for the Raspberry Pi 2, 3, or 4 if you have one. We will also set it up so you can access it on the web and 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

Optional

Video Tutorial

If you want to see how to setup 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, so you’re kept up to date.

Setting up the Raspberry Pi Minecraft Server

Firstly, we will need to install Raspbian onto the Raspberry Pi. If you haven’t already done this, then check out my awesome guide on installing NOOBs Raspberry Pi. It will take you through all the steps that you will need to do.

Important: You will need to be on the latest versions of Raspbian Buster. If not, then you will find that Java is not installed, this will need to be done if you wish to get this server working. I highly recommend updating to Jessie, Stretch, or Buster.

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 memory by not loading the GUI.

1. First, let’s bring Raspbian up to the latest version by entering the following.

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 check out our guide.

3. First, let’s go to Advanced Options->Memory Split, update this to 16. This will allow for more memory to be free for the server.

4. Also, you don’t want to boot into the Raspbian desktop, so ensure the boot option is set to the CLI (Command Line Interface) instead. This change will help give the server as much processing power as possible.

5. If possible, change overclocking to High.

6. Finally, also enable SSH so we can access the Pi remotely if required (Unless you already have it enabled).

7. Now go to finish and reboot.

8. 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 that the IP doesn’t change you might want to setup a static IP address.

8. Next, we need to make sure that Java and Git is installed. Otherwise, we will not be able to build or launch the server.

Enter the following command to install the JDK 17 package for Raspbian as well as the Git software.

sudo apt install openjdk-17-jdk git

9. Now we will need the Minecraft server file, and we’re going to use a builder tool that is supplied by Spigot, to get this enter the following commands.

mkdir /home/pi/minecraft
cd /home/pi/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-30 minutes to finish.

Add --rev 1.19.3 to the end of the command to get the latest version. Don’t forget to change 1.19.3 in the command to the latest version number.

java -Xmx1024M -jar BuildTools.jar

Important: If you have a Raspberry Pi B+, B or any variation before the Raspberry Pi 2, then the build tools will likely fail. You will need to instead generate the spigot.jar on a more powerful computer.

11. To make sure the Spigot server successfully downloaded and saved simply type ls and should see spigot-1.19.3.jar.

ls

Make sure you remain in the /home/pi/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 in there.

12. Now we’re 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.19.3.jar)

Raspberry Pi 1

java -Xms256M -Xmx496M -jar /home/pi/minecraft/spigot-1.19.3.jar nogui

Raspberry Pi 2, 3, or 4

java -Xms512M -Xmx1008M -jar /home/pi/minecraft/spigot-1.19.3.jar nogui

With the 2GB and 4GB variants of the Raspberry Pi 4, 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 now 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.

Raspberry Pi Minecraft Server

Connecting to the Minecraft Server

If you’re on a local network, then it should be pretty easy to connect to the Minecraft server running on the Raspberry Pi. To test it out, do the following steps.

Load up the Minecraft Java client on a computer within the same local network as the Pi.

Go to multiplayer and then your server might pop up in the local list. If it doesn’t simply go to direct connect and enter the IP we got earlier on the Pi using the command hostname -I.

If you want to allow access to the Minecraft server via the internet, then you will need to setup port forwarding.

Assuming you want to learn how to do this, then 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

Now to get the most out of our Minecraft server on the Raspberry Pi, we will want to install a plugin to help optimize the performance.

Firstly let’s install the NoSpawnChunks plugin, this will help prevent the Minecraft server from chewing up too much RAM.

cd /home/pi/minecraft/plugins
wget -O NoSpawnChunks.jar https://files.pimylifeup.com/minecraft/NoSpawnChunks.jar

There are other plugins out there that can help with performance or extend the servers functionality, simply use the wget command to download them to the Pi as we did above.

Editing the Minecraft Properties

Now you 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 /home/pi/minecraft/server.properties

Now in here, we will want to change a few settings to help optimize the performance of the server.

You 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.

[Unit]
Description=Minecraft Spigot Server

[Service]
User=pi
Group=pi
Restart=on-abort
WorkingDirectory=/home/pi/minecraft/
ExecStart=/usr/bin/java -Xms512M -Xmx1008M -jar /home/pi/minecraft/spigot-1.14.4.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.

If you want to get access to the server on the command line, then you will need to shutdown the server and load it using the normal command.

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.

291 Comments

  1. Avatar for Agustin
    Agustin on

    Hi, is there a tutorial to setup a bedrock server on a pi?

  2. Avatar for Aaron
    Aaron on

    My problem is that the ip is local so I cant run the server to other people. Do you know how to fix this?

    1. Avatar for Emmet
      Emmet on
      Editor

      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

  3. Avatar for Chris
    Chris on

    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.

    1. Avatar for Emmet
      Emmet on
      Editor

      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

  4. Avatar for Anonymoose
    Anonymoose on

    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!

Leave a Reply

Your email address will not be published. Required fields are marked *