Gaming Hardware Minecraft Software

How do I run a Minecraft server on a Raspberry Pi?

Minecraft
All mine: play Minecraft on your own server

Released in 2009, few recent games have had the longevity of Minecraft. Available on pretty much any platform that you can think of (I have it on about five), it’s fun for kids and adults alike. And it’s even more fun if you create your own Minecraft server on a Raspberry Pi, which I’m going to show you how to do here.

The server software is available for anyone to use and host their own multiplayer game. You can do this using any old laptop lying around but the Raspberry Pi is perfect for the job, too. Although this has been possible since the first Pi came out, it tended to be slow and needed stripping back to run effectively. However, with modern, more powerful iterations of the Pi, all of that’s changed.

In this article we’ll look at what hardware you need to run a Minecraft Server with a Raspberry Pi, tips on how to get the best performance, as well as simple instructions to install both the operating system and server software onto your Raspberry Pi.

Which Pi?

Any Pi is just about good enough to run a Minecraft server, but the more powerful version that you choose, the better the performance.

I’d recommend a Raspberry Pi 3 or later and as much memory as you can afford. I’m using the latest Raspberry Pi 4 Model B with 8GB of memory (the most memory available on a Pi). However, there can be a jump in price by as much as 25% for simply doubling the memory.

Get your kit together: hardware requirements

To build your Minecraft server you’re going to need the following:

  • A Raspberry Pi model 3 or greater (see above)
  • A good quality power supply for the Pi (the official one is a good bet)
  • A case with a fan – your server may get hot and a good quality case with a fan is important
  • A Micro SD memory card (16GB or higher)
  • An Ethernet cable (you can use Wi-Fi but a wired connection, via Ethernet, is highly recommended)

Initially, you’ll also need the following:

  • A computer running Mac, Windows or Ubuntu with a card reader so that you can add the operating system onto your memory card
  • A monitor, wired keyboard and wired mouse – these can be removed once set up is complete
  • An appropriate cable to connect the video output of your Raspberry Pi to your monitor (usually an HDMI of some kind)

Setting up Raspberry Pi OS Lite

Raspberry Pi Lite is the OS to go for. It’s command line only but, due to the headless nature of a Minecraft server, will give you better performance.

  1. Follow my guide on how to install Raspberry Pi OS Lite.
  2. Once you’ve done that, there’s a configuration change you need to make. Run the following:
sudo raspi-config
  1. Now change the default language (5 Localisation Options -> L1 Locale) to en_GB.UTF-8. The important part here is that it’s UTC-8, as the Minecraft server is formatted in UTF-8.

Update JavaJDK and the rest

Next, we want to update JavaJDK as the version that comes with the OS isn’t very up-to-date. Rather than repeat the lengthy instructions from elsewhere, head to this excellent article which explains the process.

Finally, we want to make sure everything is updated after the changes we’ve made above, so run the following:

sudo apt-get update && sudo apt-get upgrade

Installing Minecraft: Welcome to Paper

Paper is a fork of the Minecraft server software specifically aimed at improving performance, so is ideal for running on a Pi. We’re going to be using this, based on a very specific script that installs and configures this automatically for our needs.

Whilst signed into your Pi run the following:

curl https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/SetupMinecraft.sh | bash

This will ask the following questions:

  1. “Enter amount of memory in megabytes to dedicate to the Minecraft server”. This is the amount of memory that will be dedicated to the Minecraft server. The more the better, but you must leave some room for the operating system background processes. 

    If you exceed the total available memory either the server will crash or the Pi will get incredibly slow, to the point where your SSH session will start timing out. The setup script will make a recommendation, which is your available memory minus 10% for headroom. If you aren’t sure what to put just go with the recommended amount.
  2. “Start Minecraft server at startup automatically (y/n)?”. This will set the Minecraft service to start automatically when your Pi boots.
  3. “Automatically reboot Pi and update server at 4am daily (y/n)?”. This will add a timed task to the server that reboots the Pi every day at 4am. This is great because every time the server restarts it backs up the server and updates to the latest version.

And that’s all there is to it. Nothing will display – the server should just run in the background.

Testing the server

Now we need to find out if the server is indeed working properly. Do the following:

  1. On another PC, start Minecraft
  2. Select Multiplayer
  3. Click on Direct Connection
  4. Insert the IP address of your Pi (the one that you got when setting up your Raspberry Pi OS and use to remotely access it)
  5. Click “Join Server”
  6. You should now join the world running on your very own server!

Useful server commands

The following commands will start, stop and restart the Minecraft server:

sudo systemctl start minecraft
sudo systemctl stop minecraft
sudo systemctl restart minecraft

Configuring your world

Right now, your Minecraft world is using the default settings. To change these, run the following:

sudo nano minecraft/server.properties

You can now edit any of the settings. Not sure what they all mean or what you can set them to? There’s a Wiki page for that.

Press Ctrl + X to exit, making sure you confirm to save the changes first. Once that’s done, make sure you restart Minecraft (see the next section on how to do this).

There are 3 other configuration files too that you can change – bukkit.yml, spigot.yml and paper.yml (click on these links for information on what the content of these are).

Console Yourself

The server has been set up to run in the background but there are times when you may want to see a bit more of what’s happening. Or rather, not happening.

Whilst logged into your server run the following command to bring up the server console:

screen -r minecraft

This will show you any server processes that are taking place as well as provide you with a special command line prompt. You can use this to run special actions that directly affect the Minecraft server, rather than the Linux commands were we running previously. Type in help for a full list or there’s a list here.

You can also send it to the background again by pressing Ctrl+A followed by Ctrl+D.

One of the first things you may want to do, though, is make yourself an operator in the game (the Minecraft equivalent of an admin). In the console run the following, where you replace PlayerName with your Minecraft user name:

op PlayerName

In game, you’ll now be able to run the full list of commands. Just bear in mind that we’re using the Java Edition (JRE) of the game, so the commands will be limited to those available for this version of the game.

Accessing your server away from home

When you added the server IP to Minecraft earlier, that was the internal IP, which only works on your home network. To access your server from anywhere, including inviting friends and family to use it, you need to use your external IP address, which is allocated by your ISP.

To find it, whilst connected to a device on your home network, head to whatsmyip.com on any browser and it will show you.

But there’s a potential snag here. Unless your ISP provides a fixed IP address (which is rare), chances are that it will occasionally change. Your ISP may be able to provide a fixed IP address for an additional charge and there are other ways to fix this IP using third-party solutions, but that’s too large a topic to include here. Otherwise, you’re going to have to resort to keeping an eye out for the address changing and then letting all players know when it does.

So, now you have your external IP address. However, players entering it won’t connect to your server because your router has no idea which connected device it needs to transfer any traffic to/from. The next step is to set up port forwarding.

Port Forwarding

Sadly, this is another router setting that will require you to do your own research. In effect, your Minecraft server is looking for traffic via a specific port, and you have to tell the router what this is.

  • Port forwarding is often in the advanced administration section of router settings, but is relatively easy to set up once you’ve found it.
  • You will need to add a port forward for TCP/UDP port 25565 to your Minecraft server (which you’ll likely select via its name or internal IP address).

Once that’s done you should be able to add your external IP address into the Minecraft server IP field and it will connect as it did before when we used the internal IP – except, now, this can be used away from home.

Installing mods and plugins

Minecraft Paper supports plugins that are compatible with Bukkit, Spigot or Paper. A popular place to get them is at bukkit.org, where there are over 26,000 and also spigotmc.org, which has over 54,000.

To install a plugin you simply download the .jar file to the minecraft/plugins folder and restart the server. There can be more to this for each plugin, so check out any instructions for each plugin carefully.

My own build

For my own build, I’m making use of a Raspberry Pi case that has its own software controllable fan (the server may get quite toasty otherwise) and allows connection of a hard drive via a SATA port. The fan needs some software installing but otherwise it’s all pretty straightforward.

Minecraft server
My Minecraft server sitting on a bookcase

I’m also making use of an SSD as a secondary drive. You can connect one via USB, but I’m using the SATA interface provided with my case for mine.

The simplest way to take advantage of this is to use the SD card for the OS and the SSD for the Minecraft server. All you need to do is switch to the SSD drive first before you run the commands to install the Minecraft server – it will then be placed on the SSD.

About the author

David Artiss

Currently working for a technology company based in San Francisco, David has worked in IT for nearly 30 years. He is a keen gamer and happily admits to being a gadget nerd too.

Add Comment

Click here to post a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advert

Advert

Advert

%d bloggers like this: