Raspberry Pi Minecraft Server 1.13.2 / 1.14.4 Installation Script / Optimization Guide

Many things have changed since I wrote my last Raspberry Pi Minecraft Server guide.  OpenJDK is now the better supported Java for Raspberry Pi and Oracle has discontinued support for Java 8 in January 2019.  Java 11 is out and offers a ton of performance improvements. 

The Raspberry Pi 44 has also arrived!  After testing the server on the 4B 2GB version using OpenJDK 11 I was blown away by the performance and decided to write an updated guide and a script that will have you up and running in minutes.

To give you a taste of how smooth the timings are in OpenJDK 11 headless using the Paper Spigot Minecraft Server here is a nearly 2 hour session I played with my girlfriend.  This was played in survival mode on a brand new server so no blocks had been pregenerated and no settings were modified from the defaults.  Nothing is overclocked except the SD card.  There was even a village right by the spawn so many entities were in use.  Here’s the timings output report:

Raspberry Pi Minecraft Server Timings
Raspberry Pi 3B+ Minecraft Server Timings
Raspberry Pi 3B+ Minecraft Config
Raspberry Pi 3B+ Minecraft Config

RPI Minecraft Server Requirements

Minecraft Server Setup Script

SSH into your Raspberry Pi and type/paste the following commands:

wget -O SetupMinecraft.sh https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh
chmod +x SetupMinecraft.sh
./SetupMinecraft.sh

This will start the server and configuration setup process. It will ask you some questions on how you want to configure the server and then automatically download, setup and start the server. Follow the Minecraft Server setup script in-depth guide here for a walkthrough.

… and we’re done!  The Minecraft server is now in the folder “minecraft”.  To start the server type:

cd minecraft
./start.sh

The server will start in the background using the screen application.  To view the console type:

screen -r minecraft

From this console you can issue any command to the Minecraft server.  The most important one you should know is the command to safely stop the server.  This will save all players and states which is simply “stop” without the quotes. 

To get out of the console without closing the server press Ctrl+A and then Ctrl+D.  This will minimize the screen session and put you back in your main console session.  The screen session will continue to run even if you disconnect from your SSH session to your Pi!

For a more in depth guide/walkthrough of the installation script check out this post covering the setup script in depth.

Pi Specific Performance Optimizations: Storage and GPU Memory

The most important optimization you can make is high performance storage.  Read my Raspberry Pi Storage Benchmarks article to see why some storage mediums are over 1000% faster for I/O which is the most critical factor for a Raspberry Pi Minecraft server.  You can also use USB adapters for mSATA SSDs (cheap on eBay) or a USB to SATA cable if you have a 2.5″ older SSD.

If you are going to use MicroSD anyway you must use a high performance MicroSD card and overclock your SD card reader to obtain the best performance.  It is normally 50hz to ensure compatibility with the cheap low quality cards but goes all the way up to 100hz.  Storage speed is a major bottleneck on the Pi and this increases your read/write speeds. 

The second most important optimization is setting your GPU to only use 16mb of RAM.  Since RAM is at a premium on the Pi it needs need as much as possible (64 MB is used by default).  This is all done in the Raspberry Pi’s /boot/config.txt file.  Type:

sudo nano /boot/config.txt

Then place these lines at the bottom of your config.txt file:

dtparam=sd_overclock=100
gpu_mem=16

Now restart your Pi using

sudo reboot

That’s it!  If your Pi won’t boot up after doing the SD card overclock don’t panic.  Just put the SD card in any computer and remove the line dtparam=sd_overclock=100 from boot.txt.  You can do it from Windows using notepad or any other text editor on any OS as the boot partition is always visible.

If you are using a older Raspberry Pi or a Raspberry Pi Zero then you may want to overclock it as well for smooth performance in game.  My favorite guide for overclocking older Raspberry Pis is located at the one and only RetroPie project wiki page located here.  The CPU and memory overclocking is going to be the most beneficial.

Minecraft Optimizations – The Timings Tool

If you are using an older Pi or have more than a few players using the server you may need to do some optimizations.  The most important thing to understand about optimizing your Minecraft server is to understand what is slowing it down.  There is an extremely useful tool built into the Paper Minecraft server called timings.  In the intro to this post I posted a picture of the graphs from this report.

To start the timings measurements open up your Minecraft console with the screen -r minecraft command like I covered earlier.  Once in the Minecraft console type:

timings on

The longer you take timings the better insight you will get into what is slowing down your server.  It is best to play as you normally would when taking these timings so you are taking accurate measurements.  To generate the report type the following:

timings report

This will give a link to paste in a web browser to view an incredibly detailed report.

Correctly Interpreting Timings

Detailed timings broken down by category
Detailed timings broken down by category

There are several different views available.  It is important not to look only at the “Lag” category but also view the “All” category.  If you only look at “Lag” you’re only seeing part of the picture.  This is useful for identifying major “spikey” slowdowns but not the overall performance of the server.  Check the “All” tab and toggle between total, average and count to understand how your server is performing.

In this example we can see some of the more expensive operations on my server are entities and chunks.  Entities are monsters/animals/items/villagers/etc.  Chunks are the map itself.  If you are doing heavy exploring on a new server you may see very large numbers for chunks.  This is due to the Pi generating them and storing them on the SD card (slow).  If you are spending lots of time in villages or fighting monsters the entities may be high.

Applying Optimizations

If you are not getting good performance and you have ran the timings tool here are some of the usual suspects to look for and possible optimizations to apply:

  • Be careful with mods/plugins – This is one of the most frequent causes of poor performance. Some mods massively increase the load on the server. The best way to find which plugin is doing this is to disable all plugins and enable them one at a time until you see the performance issues and have isolated the problem plugin.
  • Check config files – Configuration files are server.properties, paper.yml, spigot.yml, and bukkit.yml.  If unsure about what a setting does google it or consult the documentation.  If you screw up your configuration unintentionally then you can revert it to default by removing the file and relaunching the server.
  • Lower your entity counts/ranges – Type nano bukkit.yml and in the file you will find spawn-limits: monsters: 70 animals: 15 and several others.  You may lower these numbers to limit the number of entities by type.  Type nano spigot.yml and you will find entity-activation-range and entity-tracking-range.  These control how close you have to be before the server starts making monsters see/track you.
  • Disable the Nether and The End – In server.properties.  In the sample report you will see the Nether uses CPU cycles (we never went there).  When/if your group is ready to go to the Nether you can turn it back on in the properties to re-enable it.  You may disable “The End” in bukkit.yml by setting allow-end: false.
  • Lower the view distance – This should be a last resort but on older Pi hardware or if you want more than a handful of players this is an option.  It will increase performance dramatically because it reduces chunk loading/generation.  Since chunk loading/unloading/generation is very I/O intensive the Pi is not very good at it.  Change it in server.properties and spigot.yml.

Conclusion

The Raspberry Pi performs just fine as a Minecraft server for under 5 players. You can have multiplayer in what feels and runs like a single player experience!

For optimization the most important things you can do are

  • Pick the right storage (SSD or high quality Micro SD) to be able to keep up with block generation
  • Run your timings! This will tell you exactly what is slowing your server down
  • Keep plugins to a minimum to prevent swamping the Raspberry Pi with extra instructions
  • If all else fails lower the view distance

58 thoughts on “Raspberry Pi Minecraft Server 1.13.2 / 1.14.4 Installation Script / Optimization Guide”

  1. Avatar for Heinz

    Hey. Thank you for the guide. Unfortunately the game crashes constantly (not the pi). What can I do to fix that?
    I tried undoing the overclock, changed the world. I absolutely followed your guide. Is that a known issue? Not sure if anybody will respond but I really hope so. The log says nothing about the crash.

    1. Avatar for jamesachambers

      The game crashing is a problem with the computer running it and not the Pi. Nothing changed on the Pi will address that but do some googling with any info about the crash on the PC in question and you should be able to get it going!

  2. Avatar for jakub

    Hi, great guide! I had installed server version 1.12 but my client wouldn’t log in (I found I have version 1.13 on my tablet). So I started to search and found your guide. I installed everything successfully and started the server. But I can’t find it from my 1.13 client. The server is 1.14 and I don’t know how to change it (I’m running headless Raspi). At least the 1.12 I was able to see in the Friends tab 🙂
    Any suggestion for me (a noob)? Thanks!

  3. Avatar for Adam

    Whenever I close my ssh session the server shuts down. How do you keep the server running without leaving an ssh session open?

    1. Avatar for jamesachambers

      Hey Adam,

      The trick is to use the screen program. If you do a screen session and then press Ctrl+A then Ctrl+D it detaches the screen session and continues to run it in the background.

      The script should use these for you but if you run things manually make sure you’re in a screen session and detach!

  4. Avatar for Bob

    Great set up, easy to do, and honestly one of the best things that my housing mates and I did… until it stopped working about a week ago. Was wondering if we could get some help and input as all attempts to get the server up and running again have been met with only limited success at best.

    Currently, we have the server running on a Raspberry Pi 4 with 4 gig of memory, using a 32 bit Raspbian operating system. Following the directions from your old walk through, with the updates given here, we had the server up and running since the end of August. However, after a scheduled restart, we’ve run into the issue where the server no longer starts up, and attempts to use the start.sh file generally end in one of two ways. Either it gets so far as checking for an update to Paperclip.jar before crashing or just crashes on start.

    After downloading all of the world backups on a separate flash drive, we have gone so far as to completely wipe and reinstall the Raspbian op onto the Pi, and then done exactly the steps outlined above. The new server will start up normally, and will stop and restart according to the program. However, when the Start.sh file is used, again we run into the same issues of server crashing. As well, the server will not start on start up anymore if we do a restart via the Raspbian OS. The backups seem to be unaffected, as we have been able to get them to run on a separate Windows computer.

    Frankly we are at a loss, and would love some help at figuring out why the server won’t start up anymore on our Raspbian system anymore. Any input would be welcome, and I am happy to answer any questions you might have in order to get this resolved.

    Again, thanks for the walk through, as it was working like a dream before this happened.

    1. Avatar for jamesachambers

      Hey Bob,

      That’s awesome that it’s one of the best things you guys have done!

      I’d say the fastest way to narrow things down is to run the server from the command line manually. Go to the minecraft folder on the Pi and run the following command:

      java -jar -Xms400M -Xmx2600M paperclip.jar

      I picked 2600M because it’s slightly under the memory cap for 32 bit Raspbian which should give the server a little bit of breathing room. If anything goes wrong it will give you an error that is easy to paste in here and we can figure out what’s going wrong!

  5. Avatar for Paco

    Hello James,

    My son and I followed your guide some time ago and it worked pretty fine in a Pi3B.
    Now we have come back to Minecraft, and found this new guide.
    Everything works even better and we are having a very nice time trying to understand and solve the issues we find.

    Thank you very much

  6. Avatar for IJuanTM

    Hi,

    I’ve a question. Which value should the memory split be in th raspi-config with this server? Is it 16 like with the older minecraft server guides? Or is another value recommended?

    Thanks!

    -IJuanTM

  7. Avatar for Kacper

    Hello,
    I have the following problem starting the server.
    On the server side I get the message:
    “[18:29:43 INFO]: com.mojang.authlib.GameProfile@161aab0[id=,name=KacperRaster,properties={},legacy=false] (/192.168.1.116:54409) lost connection: Disconnected”

    And on the Minecraft side: login failed, session expired, restart game or luncher

    1. Avatar for jamesachambers

      That’s an interesting one. The com.mojang.authlib.GameProfile component is what talks to Mojang when players join your server to retrieve their player game profile such as what skin they have selected, if they have a valid license for the game, etc. The connection to that server is being force closed on it during the middle of authorization so it is kicking you out immediately afterward.

      This is usually a firewall issue. When you connect to the server are you using the public IP or the private IP? I would recommend using the private one (192.x.x.x or 10.x.x.x usually) if you’re on the same network as the Pi as some firewalls aren’t properly configured for hairpin NAT. Also check all rules on any software/hardware firewalls and make sure everything looks good.

      You may also try adjusting the “online-mode” setting in server.properties which can disable checking with Mojang at all. This is a possible solution if you toggle it and the server works fine otherwise.

      This is a fairly uncommon

  8. Avatar for Firejoust

    Hi James,
    Would it be possible to run a 64 bit distribution of java on a raspberry pi 4? I want to run a minecraft server with more than 2gb but can’t figure out how to install java 64 bit.

    1. Avatar for jamesachambers

      Yes it’s absolutely possible but you need a 64 bit operating system as well which unfortunately rules Raspbian out (unless you rebuild the kernel as 64 bit which is possible but takes some effort).

      I just did it last night finally for the first time after building the kernel myself (Ubuntu Server 18.04.3) and am working on finishing it up. I was able to allocate the full 4GB of RAM to the server which Raspbian can’t do (you can do up to 2700 on Raspbian 32 bit so if you are only using 2000 go ahead and bump it up to 2700!).

      I’m continuing to work on this and plan on posting some instructions precompiled kernels to help people get 64 bit going while the official support catches up.

Leave a Comment

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

Type here..