Family Encyclopedia >> Electronics

How to turn your Raspberry Pi into a Minecraft server

Minecraft is the second best-selling video game of all time, with 122 million people online in September 2019 alone. While you can explore the world of Minecraft solo, some things are more fun with friends! By creating your own Minecraft server, you will have full control over your world:you can set your own rules, install mods and invite all your friends to explore Minecraft with you!

SummaryWhat You'll NeedMake Sure You're Using RaspbianUpdate Raspbian's Memory MapOptional:Allow SSHC ConnectionsCreate a Spigot ServerConnect to Your Minecraft Server Start Your Server Automatically

In this tutorial, you'll learn how to set up and host a standalone Minecraft server on your local Wi-Fi network using Raspberry Pi. Once this server is up and running, you'll be able to play with anyone else connected to your network – great if your kids or housemates are obsessed with Minecraft!

How to turn your Raspberry Pi into a Minecraft server

Once your Raspberry Pi has booted up, you'll need to make sure your version of Raspbian is up to date. Launch a new Terminal window by clicking the Terminal icon in the Raspbian toolbar, then run the following commands:

sudo apt-get updatesudo apt-get upgrade

Raspbian will now download and install all available updates. If prompted, restart your Raspberry Pi using the following command:

reboot

Update Raspbian memory-map

Next, you need to tell Raspbian how it should use the available memory using the configuration tool.

You can launch this tool using the following Terminal command:

sudo raspi-config

In the window that appears, navigate to "Advanced Options ->Memory Allocation" and enter the value "16". Save your changes by clicking "OK".

Optional:allow SSH connections

If you ultimately want people to be able to connect to your server remotely, now is a great time to enable SSH:

1. From the toolbar, select the Raspberry Pi icon.

2. Go to "Preferences -> Raspberry Pi Configuration".

How to turn your Raspberry Pi into a Minecraft server

3. Select the “Interfaces” tab.

4. Search for "SSH" and select the accompanying "Enabled" radio button.

How to turn your Raspberry Pi into a Minecraft server

5. Save your changes by clicking "OK".

6. Restart Raspberry Pi by clicking the small icon in the upper left corner and navigating to "Shutdown -> Reboot" or running the reboot command in Terminal.

Create a Spigot server

We'll be building our server using Spigot, which is a modded Minecraft server that includes some useful performance optimizations.

The first step is to ensure that Java is installed on the Raspberry Pi. You can install the default JDK package for Raspbian using the following command:

sudo apt install default-jdk

Next, you need to create the Minecraft server file. For convenience, this tutorial uses the authoring tool provided by Spigot. In the Terminal window, run the following three commands:

mkdir /home/pi/minecraftcd /home/pi/minecraftwget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar

Create your Spigot server:

java -Xmx1024M -jar BuildTools.jar --rev 1.15.2

Note that in the command above, Spigot 1.15.2, which at the time of writing was the latest version, is used. If a newer version is available, then update --rev to reference the latest version.

Once Spigot is downloaded, you can launch your server:

java -Xms512M -Xmx1008M -jar /home/pi/minecraft/spigot-1.15.2.jar nogui

Remember to modify the above command if you are using a version other than Spigot 1.15.2!

Before launching, the server will ask you to accept the Eula (End User License Agreement).

How to turn your Raspberry Pi into a Minecraft server

You can open the Eula in Raspbian's Nano text editor:

nano eula.txt

In this file, change "FALSE" to "true", then save your changes using the Ctrl + X shortcut followed by yes . Finally, press the Enter key on your keyboard.

How to turn your Raspberry Pi into a Minecraft server

Now you need to restart the server, so restart Raspberry Pi by entering the reboot command in the terminal.

Your Raspberry Pi will now reboot, and when it's back up and running, you'll be ready to connect to your server!

Connection to your Minecraft server

To connect to the Raspberry Pi server, you need to know its IP address. To retrieve this information, open Terminal and run the following command:

sudo hostname -I

Launch Minecraft Java Edition on your laptop or computer.

How to turn your Raspberry Pi into a Minecraft server

Select "Play -> Multiplayer".

How to turn your Raspberry Pi into a Minecraft server

Your server should automatically appear in the local list, but if you can't locate it:

  • Select "Add Server".
  • Enter the IP address of your Raspberry Pi.
How to turn your Raspberry Pi into a Minecraft server
  • Click "Done".

You should now be successfully connected to your Minecraft server.

How to turn your Raspberry Pi into a Minecraft server

Start your server automatically

Why bother starting your server manually when you can configure it to start automatically?

To start your server on boot, you will need to create a new service for the Minecraft server, so open a Terminal window on your Raspberry Pi and run the following command:

sudo nano /lib/systemd/system/minecraftserver.service

In the Nano text editor, type the following:

[Unit]Description=Minecraft Spigot Server[Service]User=piGroup=piRestart=on-abortWorkingDirectory=/home/pi/minecraft/ExecStart=/usr/bin/java -Xms512M -Xmx1008M -jar / home/pi/minecraft/spigot-1.15.2.jar nogui[Install]WantedBy=multi-user.target

Save this file using the Ctrl + X keyboard shortcut, then press the yes and Enter keys when prompted.

You can now enable the service using the following command:

sudo systemctl enable minecraftserver.service

And finally, you can start your Minecraft server:

sudo systemctl start minecraftserver.service

Your server should now start automatically every time you turn on your Raspberry Pi.

Now you can customize every part of your Minecraft world and play with your friends and family. Currently, your server is only accessible on the local network, but you can allow people to connect to your server from outside using port forwarding.

Have you set up your own Minecraft server? If so, we would like to know how you use your server to create unique and interesting Minecraft worlds.