Raspberry Pi Minecraft Server 1.12.2 Installation Script / Optimization Guide

ATTENTION:  This guide has been updated for version 1.13+ – Click here to view the updated version!

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 3B+ has also arrived!  After testing the server on the new 3B+ using Java 9 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 Java 9 OpenJDK 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

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

cd minecraft

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!

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:


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:

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


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

28 thoughts on “Raspberry Pi Minecraft Server 1.12.2 Installation Script / Optimization Guide”

  1. Thanks for the tutorial ! The controls works on Asus Tinker Board? And 16GB SD is enough for the minecraft server and the bone?

    1. Absolutely. I haven’t picked up an ASUS Tinker Board yet but as long as they have a java9 or java8 JDK package it should work just fine. 16GB is also plenty of memory!


  2. What would you recommend for the max number of players for the Raspberry Pi 3 B+? I currently just have the Raspberry Pi 3 and I have the max players set for 8 with seems to work quite well. I was wanting to upgrade it to the B+.

    1. I have heard of people getting 12 players on there quite comfortably on the 3B+. I would start there and slowly add and see how the server is running. Definitely monitor the timings and see if you are having any problematic areas on the server that may be leading up to lag.

    1. I’d recommend around 700-800MB. This leaves room for the base services on the Pi to still run. If you push the base services into the swap it can cause the Pi to crash or slow down dramatically.

      If you disable some services on the Pi it can definitely free up a small amount of room to squeeze out a little more but 800MB is pretty sufficient. You can experiment with higher and see if the Pi can handle it but I’d start at 700 and work up from there.

    1. jamesachambers

      The best way is using a system service as a daemon. I will make a post on how to do this as I have been creating daemons for other things I have been working on.

  3. When I do the command “./start.sh” without the quotes this is what is returned

    Starting Minecraft server. To view window type screen -r minecraft.
    To minimize the window and let the server run in the background, press Ctrl+A then Ctrl+D
    ./start.sh: line 6: screen: command not found

    How can I fix this?

  4. How do I load a minecraft save into the world? every time i copy the contents of another world into ‘world’, it just gives me errors about session.lock

    1. Make sure that you have the server closed when you are trying to copy your world over and then start the server afterward. The server creates a session.lock file when it is running.

        1. Yes. If you are certain that the server is closed and there is a stale session.lock file then it should be safe to delete it and start the server.

          Check out this link from the Minecraft wiki about session.lock. It is meant to make sure that the last program the accessed the world continues to be the only program that can access it. Since you are moving the server over, this behavior is not desired and it is safe to delete the session.lock. When the server runs it will create a new one saying your Pi server now owns the world. If you transferred the world again in the future back to a different platform you would delete the session.lock again to release the world.

          If you have further trouble you can chmod 777 world or session.lock. See this answer if just sudo rm session.lock inside the world folder doesn’t work for you.

  5. Thanks for this post, it is the most comprehensive tutorial I have found about creating a minecraft server on rbpi 3.

  6. You list a “SanDisk Extreme 128GB Solid State Flash Drive” but I don’t see anything that explains why or how to use that. I’m assuming it’s in place of the MicroSD card

    1. Sorry about the lack of clarification there. I will update that section to clarify. You are correct in that I am suggesting using a solid state based flash drive over a MicroSD card. Check out this article to see why.

      In a nutshell, solid state with the Pi outperforms even the most expensive MicroSD cards by a huge margin. Even cheap based makeshift drives (also described in linked article) maxed out the bus in a way that MicroSD can’t. Since Minecraft is very I/O intensive with constant chunk generation and loading having fast storage is critical for good performance.

    1. The Paper server project is built on top of Spigot which has had a 1.13 server up for testing publicly for months now. I expect support for 1.13-pre1 to come to Paper very soon.

  7. I got the fast 32 GB SD card and followed the directions. I get the Pi to launch but I can’t connect. I “think” I have port forwarding correctly setup on my router. The question that hits is how do I know? How do I check? I don’t know if it is my work or a version incompatibility with Minecraft on my family’s iPads and my laptop. Any thoughts would be appreciated.

    1. It sounds like you are using the Minecraft Bedrock edition (which is the one that comes with Windows and the available version for iPad).

      This server is for the Java edition available at Mojang.com.

  8. Hey James (I’m migrating from your I/O Optimization post!)

    Great guide here as well. I have the exact same setup with the SanDisk Extreme Pro USB Flash Drive and it works well most of the time!

    I am however getting really random performance dips where the server will have a consistent 4-6 second lag that last anywhere from a minute to several hours. I’ve tested the server with just myself and upwards of 7 people now and regardless of the number of players the performance variation remains.

    We’re all loving it, but I’d really be happy if I could squash out these hiccups and get a nice smooth sailing experience. I just wanted to know what kind of optimizations you’ve done outside of what’s written in your post?

    I am using just the regular server.jar that mojang has to download and not the paperclip, so I don’t have the spiggot or bukkit configuration files. I tried using paperclip for a period of time but it was just giving some of the same issues. I make sure to utilize some java flags like setting the memory usage to 800M.

    I have skepticism about thermal throttling of the R.pi, mine get’s pretty hot. I have heatsinks on the two main chips but that’s about it. I also wonder if it could maybe be a networking thing? However, whenever I host the server with the same settings on a stronger desktop on the same network I’m seeing the issues go away. Did you tweak anything in either of these areas to optimize performance?

    Would love to hear what you have to say, keeping the R.pi as a permanent server setup is a dream!

    1. Hey Zaner,

      The main things outside my original post depend on what kind of server you are running and what you want to do. The most important thing to do first is figure out what is slowing down the server. Have you ran the timings tool on the server to determine where the spikes are and what the server is doing when they occur?

      Some examples of optimizations I’d do: monster/animal view and action distance can be lowered in a lot of situations, lowering the view distance in the game can help with block chunking I/O issues, pregenerating the map in MCEdit can help if block reads/saves are slowing you down, reducing save timers can help if it’s getting stuck while autosaving various parts of the game by making them less frequent, etc.

      I could definitely assist if you posted a link to your timing results.

      For heat throttling affecting your performance this is definitely a possibility. The Raspberry Pi will downclock itself around 85C. Further, running very hot is a known problem with the Raspberry Pi 3. Check out this article to see some of the best info on this: https://makezine.com/2016/03/02/raspberry-pi-3-not-halt-catch-fire
      Have you taken measurements as to what temperature your Pi is reporting?

      In this article I used a Pi 3B+ which came with the little heatsinks installed and didn’t do any additional tweaks regarding heat. If you’re running without the heatsinks this is where I would start. A few degrees being pulled off the chips by the heatsink may make all the difference in stabilizing the board’s performance and they only cost around 5 bucks from Amazon for the whole kit (get one with good reviews, the super cheap ones don’t conduct very well).

      Also check out this article where I use a fan to provide direct cooling to a RPI: https://www.jamesachambers.com/2017/07/old-skool-nes-classic-case-fan-mod/
      Although you aren’t running RetroPie on the box we may find via your temperature readings that you are hitting temperatures where you may need to provide some active cooling. This little fan powered by the RPI itself is pretty nifty but you can also just put a normal desk fan right over the Pi to pull heat off it (especially with the heatsink kits).


  9. okay so i have followed your step by step instruction in this page. i have minecraft on my android phone but i’m unable to connect to world. I feel like i’m missing something? i’m a complete NOOB when i comes to this. would like to get this going for my kids who play minecraft on there phones. Please help

  10. Hey James,
    first of all thanks for sharing you knowledge and work! Especially with your script and detailled information you make it super easy for us guys. I appriciate that.
    Anyway, I run across two problems. Here’s my setup: Server is hostes on my RPi 2B+. Game is played on my RPi 3B+.

    First problem: The server installed with your script is 1.13.2 and I think at the moment 1.12.1 ist the latest running client on my Pi 3. I see two options.
    Option 1: Using your “outdated” manual installation guide to install an older server version. And since in the future I’ll have to wait for people to get the latest MC version running on the Pi, I guess that’s my best option to go for and not beeing dependent on scripts.
    Option 2: Simply getting the 1.13.2 MC client running on my Pi 3.
    Probably I can fix this problem by myself, but some tips are welcome.

    THE REAL PROBLEM: Shortly after starting the server and everything is loaded, I get a bunch of red error lines in the screen window. And even though it states that “THIS IS NOT A BUG OR A CRASH”, none of my friends are able to connect to the server. The error lines are like app//com.majong.datafixers…, java.base@9-Raspbian/java.util…, app//org.bukkit.craftbuild…, app//net.minecraft.server.v1_13_R2…, etc.
    I don’t even know what that means and by consequence how to fix it.
    Can anyone help??

    1. Hello Sahin,

      I think I can help! The Paper Minecraft server still supports the 1.12.2 branch. My understanding is that 1.13 introduced the new version of LWJGL that hasn’t been ported to ARM yet so if you can upgrade to 1.12.2 there are still supported versions of the server. Check out this link for the downloads: https://papermc.io/downloads#Paper-1.12. You can still use all of the current scripts, you will just replace paperclip.jar with the one from the linked site. Here’s a link of the guy running 1.12.2 on RPI: https://www.raspberrypi.org/forums/viewtopic.php?t=208027

      Now to address the real problem section. A couple of things: Is this a brand new server or is this your 1.12 server now running on the 1.13 server? There are some version compatibility issues between the two. It would also help to see the full error message. There’s actually some useful info buried in the 20+ lines it spits out every time it has an error so pasting a full copy would help as well. From what you posted I see a DataFixer exception. The DataFixer class is the class that helps manage data between different Minecraft versions which would point to my original theory.

      If you go the 1.12.2 route then it would be best to load up a backup from before the 1.13 server ever touched it as moving forward is difficult enough and moving backward is impossible once 1.13.2 put its own data structures in there. Let me know what you think and if this is a new or existing server and paste in some samples of the full error and we should be able to get it straightened!

Leave a Comment

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

Type here..