Self Hosted Minecraft Server on Raspberry PI with SpigotMC


Last Updated on 2nd September 2023 by peppe8o

In this tutorial, I’m going to show you how to setup a Java Minecraft Server on Raspberry PI.

The best-selling video-game of the world, Minecraft is loved by young and old and what you can do is limited only by your creativity. As renting a server may have costs, you can run your little Minecraft Server on Raspberry PI avoiding to pay for external hosting.

Minecraft Server

Before starting, there are some important clarifications to be made.

This tutorial regards installing a Minecraft server, but you need a client to run on it. Please note that clients are not covered by this article and usually require a monthly fee (please visit the official Minecraft website for more info about client). I was able to test that server was up and running correctly, but I don’t have a Minecraft account to test how it performs. It would be really appreciated if someone could give me feedback on the client side experience.

Minecraft logo

Another important consideration regards performances. I’ve created this procedure for a Raspberry PI 3 model B+. Even if it is an amazing board, a Minecraft server is really expensive in terms of resources (CPU and RAM). Better results will be achievable with a Raspberry PI 4 Model B (models with more RAM are better), but you won’t probably get the same performance as dedicated servers. Anyway, you should get a good experience by using some tricks included in this tutorial (as reducing concurrent player’s number and the view distance).

If you want to expose this server on the internet, you have to check with your Internet Service Provider that your router IP is a public one. A detailed explaining of this topic is available from my No-IP with Raspberry PI tutorial. If you have this requirement, you will also have to set a port forwarding in your router for port 25565 (Minecraft default port) or whatever port you decide to set. Also securing (with a password and/or reverse proxy) a server exposed to the internet is always a good idea. On the other hand, if you can’t get a public IP, you should anyway be able to use your Minecraft server from your home network.

That said, let’s go with the setup procedure.

What We Need

As usual, I suggest adding from now to your favourite e-commerce shopping cart all the needed hardware, so that at the end you will be able to evaluate overall costs and decide if to continue with the project or remove them from the shopping cart. So, hardware will be only:

  • Raspberry PI Board (including proper power supply or using a smartphone micro usb charger with at least 3A). Raspberry PI 3 Model B (or B+) is, in my opinion, the minimum. A Raspberry PI 4 Model B is surely better.
  • high speed micro SD card (at least 16 GB, at least class 10)

Check hardware prices with following links:

Amazon raspberry pi boards box
Amazon Micro SD box
Amazon Raspberry PI Power Supply box

Step-by-Step Procedure

Prepare Operating System

Start installing Raspberry PI OS Lite. I suggest not using the Desktop version as you would waste resources with a desktop environment and with projects like this every MB of RAM or CPU percentage is vital.

Make sure your OS is up to date. From terminal, use the following command:

sudo apt update -y && sudo apt upgrade -y

Following are tricks to make your OS a bit more performing.

The first one is loading the 64-bit kernel for your Raspberry PI. This can be done by editing the config.txt file:

sudo nano /boot/config.txt

and appending the following parameter at the end:


This trick will be running after a reboot, which we’ll make later.

The second trick is increasing the swap memory, as explained in my Set Raspberry PI swap memory tutorial. Set CONF_SWAPSIZE to 1000

The third trick is reducing memory split to the minimum value (16MB) so that all RAM will be dedicated to computing instead of graphic card. Also for this operation you can refer a tutorial of mine: Manage Raspberry PI GPU Memory Split

After the last trick, you can reboot you Raspberry PI.

Install Java

Last Minecraft server versions require Java 16 to run.

You can check if aptitude has released this version:

sudo apt search jdk-headless

You will probably find that available version from apt is lower than required. For this reason, we need to get it from a different source. As referred from, use the following terminal commands.

Download from github the openjdk16 binaries:


Uncompress into a folder from your Raspberry PI (I will use /opt/):

sudo tar xzf OpenJDK16U-jdk_arm_linux_hotspot_2021-05-08-12-45.tar.gz -C /opt/

Add the new path for java into the PATH system variable:

export PATH=/opt/jdk-16.0.1+4/bin:$PATH

With this, you will have java 16 running in your Raspberry PI:

pi@raspberrypi:~ $ java -version
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+4-202105072340 (build 16.0.1+4-202105072340)
OpenJDK Server VM AdoptOpenJDK-16.0.1+4-202105072340 (build 16.0.1+4-202105072340, mixed mode)

But this will be reset at every reboot as the export command executed from bash expires when session is closed. To make it permanent, open the profile file:

sudo nano .profile

and append at the end the export path command:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then

export PATH=/opt/jdk-16.0.1+4/bin:$PATH

Close and save.

Install Spigot Minecraft java server

Spigot installation requires having git command:

sudo apt install git

We’ll also create a folder to include all Minecraft server files:

mkdir minecraft
cd minecraft

Please remember that I’m creating this folder in my default “pi” home (/home/pi). If you use a different folder or a different user, this will be important in the following parts.

The Spigot installation procedure builds the jar server in your Raspberry PI, resulting in a simple package construction.

First, start downloading the jar file to build your server:


The configure git:

git config --global --unset core.autocrlf

Here ways go differently depending on your Raspberry PI model. If you have a Raspberry PI 3 Model B, you have up to about 1GB of RAM, while the RPI 4 model B can be with 2, 4 or 8 GB of RAM. Following java commands make use of the Xmx and Xms options to limit memory usage (both in MB). Xms sets the memory dedicated when the java command is launched, while Xmx limits the memory usage available for your Java Virtual Machine (JVM). I suggest not to set these values at your maximum but leave a bit of RAM available also for OS. I’ve used the following values with a Raspberry PI 3 model B+ (1GB), but if you have more RAM set them accordingly.

Run the builder:

java -Xmx750M -jar BuildTools.jar

This command will require time… take a cup of tea and wait for execution to end (or use your time browsing other articles from 🙂 ). When finished, you will find in your Minecraft folder a new jar file, named according to the Spigot version available at your execution, mine one being ” spigot-1.17.1.jar” (please take note of your version file if different from mine also for following commands). This will be the real Minecraft server Java package. You will require a very first run to initialize some variables. From terminal:

java -Xms512M -Xmx768M -jar spigot-1.17.1.jar nogui

This first run will end suddenly with following error:

pi@raspberrypi:~/minecraft $ java -Xms512M -Xmx768M -jar spigot-1.17.1.jar nogui
Loading libraries, please wait...
[10:18:44] [main/ERROR]: Failed to load properties from file:
[10:18:44] [main/WARN]: Failed to load eula.txt
[10:18:44] [main/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.

It created 2 files: an “eula.txt” and a “”. Edit the eula.txt if you agree with terms available from link inside the txt:

nano eula.txt

change “eula=false” to “eula=true”. Save and close.

Also make some editings in your file:

sudo nano

Identify and modify the following parameters to get better performances:


You will be able to change these settings later to reach a good balance according to your installation performances.

Finally, run your Minecraft server with same command:

java -Xms512M -Xmx768M -jar spigot-1.17.1.jar nogui

Again, the very first run will take several minutes. Also following boots will take time, but should be faster. At the end you can get a message like the following:

[10:31:11] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 13591ms or 271 ticks behind

This happened to me too but didn’t seem to impact my setup. The following row will give back to us the Minecraft server command console:

[10:31:11] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 13591ms or 271 ticks behind

If your Minecraft server is exposed to the internet, you will be able to check your installation with the following online tool:

I experienced that my Minecraft was notified as working after a few more minutes. Take patience…

Create Minecraft Service on Systemd

You will notice that your Minecraft server on Raspberry PI will shut down every time you will logout. To solve this you need to create a systemd service:

sudo nano /etc/systemd/system/minecraft.service

Insert following code, taking care to use your directories and spigot file name:

Description=My Minecraft Server

ExecStart=/opt/jdk-16.0.1+4/bin/java -Xms512m -Xmx750m -jar spigot-1.17.1.jar


Close and save. Reload systemd services list and enable minecraft.service to run on system boot:

sudo systemctl daemon-reload
sudo systemcts enable minecraft.service

From here you will be able to manage your Minecraft installation from common systemd commands like, for example, the status one:

pi@raspberrypi:~ $ sudo systemctl status minecraft.service
 minecraft.service - My Minecraft Server
   Loaded: loaded (/etc/systemd/system/minecraft.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2021-07-22 15:44:06 BST; 2h 6min ago
 Main PID: 332 (java)
    Tasks: 27 (limit: 1071)
   CGroup: /system.slice/minecraft.service
           └─332 /opt/jdk-16.0.1+4/bin/java -Xms512m -Xmx750m -jar spigot-1.17.1.jar

Jul 22 15:51:01 raspberrypi java[332]: [15:51:01] [Worker-Main-6/INFO]: Preparing spawn area: 87%
Jul 22 15:51:01 raspberrypi java[332]: [15:51:01] [Worker-Main-6/INFO]: Preparing spawn area: 87%
Jul 22 15:51:01 raspberrypi java[332]: [15:51:01] [Worker-Main-4/INFO]: Preparing spawn area: 87%
Jul 22 15:51:02 raspberrypi java[332]: [15:51:02] [Worker-Main-5/INFO]: Preparing spawn area: 89%
Jul 22 15:51:02 raspberrypi java[332]: [15:51:02] [Worker-Main-6/INFO]: Preparing spawn area: 93%
Jul 22 15:51:03 raspberrypi java[332]: [15:51:03] [Worker-Main-4/INFO]: Preparing spawn area: 98%
Jul 22 15:51:03 raspberrypi java[332]: [15:51:03] [Server thread/INFO]: Time elapsed: 26172 ms
Jul 22 15:51:03 raspberrypi java[332]: [15:51:03] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
Jul 22 15:51:03 raspberrypi java[332]: [15:51:03] [Server thread/INFO]: Done (305.727s)! For help, type "help"

Please let me know your feedback!

How useful was this post?

Click on a star to rate it anonymously!

Average rating 4.8 / 5. Vote count: 5

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?