Daniel Lemire's blog

Setting up a “robust” Minecraft server (Java Edition) on a Raspberry Pi

My kids are gamers, and they love Minecraft. Minecraft sells its client software, but the server software is freely available. Since it is written in Java, it can run easily on Linux. Meanwhile, you can order neat little Raspberry Pi Linux computers for less than $50. So, putting two and two together, you can build cheaply a little box (not much bigger than my hand) that can be used as a permanent, low-power, perfectly silent game server. And you can expose your kids to servers, Linux and so forth.

There are many guides to setting up a Minecraft server on a Raspberry Pi, but the information is all over the place, and often obsolete. So I thought I would contribute my own technical guide. It took me a couple of long evenings to set things up, but if you follow my instructions, you can probably get it done in a couple of hours, once you have assembled all the material.

We are going to setup a Minecraft server for the old-school Java-based Minecraft. There are other Minecraft versions (e.g., on mobile devices) but they require different software. To be clear: if you are running Minecraft on a smartphone, a console or a tablet, it is probably not compatible with the regular Minecraft.

My instructions have been tested thoroughly and they work. I recommend you pay close attention to each step. It is not difficult, but you need to be conscientious.

You can take liberties and improvise, but if you do so, please understand that you are likely on your own to fix the problems you create.

Prerequisites

Instructions

And voilà! The result is a “robust” and low-cost Minecraft server.

If you ever need to stop the server, just log in with ssh, use screen -r minecraft to get to the server prompt and type stop. At the bash prompt, type sudo shutdown -h now. Wait a few seconds, then unplug the Raspberry Pi.

The add a Minecraft plugin, drop the corresponding jar file in the plugins directory under the minecraft directory (/home/pi/minecraft/plugins) and restart the server (type stop in the server prompt and relaunch minecraft.sh). You can recover plugin jar files from the Internet using the wget or curl commands in a shell followed by the URL such as wget http://thedomain.com/theplugin.jar. If you misplaced the jar file on the Raspberry Pi, you can move it to the right directory with the mv command: mv theplugin.jar /home/pi/minecraft/plugins. If you have the plugin jar files on your Windows PC, you can use sftp to upload them to the Raspberry Pi from your PC. There are free sftp clients such as WinSCP.

You can easily setup several such servers, just buy more Raspberry Pis!

Next, you can make the server available on the Internet using a service like dyn.com, and some work on your router to redirect the Minecraft port (25565) from your router to the Raspberry Pi. It is not very difficult to do but it requires you to know a few things about how to configure your router. You should also be aware of the security implications. I am not going to tell you how to do it because the specifics depend on your exact configuration, on how you access the Internet, how your router is configured and so forth. At best, I could describe various scenarios, but if things go wrong, it could leave you without Internet, with security hole, or with a violation of the terms of services of your Internet provider. So you are on your own if you want to expose your server to the Internet at large.

Want to get your Raspberry Pi to do something different? I recommend simply switching to a different SD card containing the latest Linux distribution for Raspberry Pis. It is generally faster to start anew than to reconfigure a machine and given how inexpensive SD cards are. Don’t waste time reusing an existing card.

You may wonder why setting up a Minecraft server is so complicated. Can’t I or others just package the servers so that it is plug and play? We are limited because the copyright owners of Minecraft do want us to ship ready-to-run Minecraft servers. It should be possible, however, to largely automate the steps that I have outlined. I leave it as an exercise for the reader.

Is there any point to all of this? Probably not. Minecraft servers like Spigot are memory hungry and the Raspberry Pi has little memory. However, the project has stretched my imagination and made me think of new possibilities. I used to recycle old PCs as home servers to provide backups and caching for various projects. I got tired of having old, noisy and bulky PC in my home… but I could literally stack a cluster of Raspberry Pi computers in a shoe box. The fact that they are silent and use little power is really a blessing.

Extra: What if you have installed the Minecraft server, and now want to upgrade it? Sadly, there is no built-in support for in-place updates in Spigot as far as I know. When the software does not support updates, many things can go wrong if you try to force an update so I simply recommend against updates. If you need a new version, just reinstall a new version from scratch. If you want to explore with in-place updates despite my contrary advice, one comment to this post describes a possible approach, but I do not recommend it particularly. It is at your own risks.

Further reading: A short version of this blog post is a chapter in the book “Creative projects with Raspberry Pi” by K. Kearney and W. Freeman.