How to Make a Minecraft Server on Raspberry Pi

Raspberry Pi Minecraft Server
(Image credit: Future)

If you want to create a private Minecraft world that you can share with your friends online, you need a place to host that experience. You can pay a hefty $7.99 per month for Minecraft Realms, which is easy to use but doesn't have all the customization options or you can rent a Minecraft server from a paid hosting service such as Shockbyte. Or you can set up your very own Minecraft server on a Raspberry Pi and have it hosted right from your living room for free. 

Note that you'll need either a Raspberry Pi 3 or 4, preferably a 4 with at least 2GB of RAM. And all the traffic on the server will be going in and out via your home internet service so, if you're planning to have a ton of users on all the time, it may take up some bandwidth. But if you're just planning to play with a few friends, creating a Raspberry Pi Minecraft server is easy, cheap and fun. 

Below, we'll show you how to set up a Minecraft server on your Raspberry Pi, make sure that server starts at boot and that it allows connections from outside your local network. We'll also explain how to log into that server from Minecraft Java Edition. Note that we're using a plain, vanilla Minecraft server and Java Edition, without mods. However, once you've got the hang of these instructions, you can install server-side mods or different versions of the server.

How to Set Up a Raspberry Pi Minecraft Server

1. Set up a Raspberry Pi if you don't have one already. See our stories on how to set up a Raspberry Pi or how to set up a headless Raspberry Pi (if you want to control it remotely). 

2. Open a terminal window on the Pi or an SSH connection to the Raspberry Pi.

3. Make sure your Raspberry Pi is up to date, by running the latest update commands.

sudo apt update
sudo apt upgrade -y

4. Install JDK and git. The Java Development Kit (JDK) is the foundation for Minecraft Java Edition. Without the JDK Minecraft would not work.

sudo apt install default-jdk

5. Create a directory to store the files and enter that directory. We'll call ours mcserver.

mkdir mcserver
cd mcserver

6. On your PC, navigate to the Minecraft.net server download page and copy the address of the latest server jar file.

Copy link address from server

(Image credit: Tom's Hardware)

7. Enter wget <URL> at the command prompt where <URL> is the URL of the jar file you copied. For example, ours was:

wget https://piston-data.mojang.com/v1/objects/f69c284232d7c7580bd89a5a4931c3581eae1378/server.jar

8. Launch the server using the following command. This will allocate 1GB of RAM to the server and then run the downloaded .jar file.

java -Xmx1024M -Xms1024M -jar server.jar

Add nogui to the end if you want to launch without an interface. You will get an error message saying that you need to agree to the EULA.

error message asking for EULA

(Image credit: Tom's Hardware)

9. Open eula.txt for editing. It's easiest to use nano.

nano eula.txt

10. Change eula=false to eula=true in the file and hit CTRL + X then press Y and Enter to save and exit.

set eula=true

(Image credit: Tom's Hardware)

11. Launch the server again.

java -Xmx1024M -Xms1024M -jar server.jar

It will take several minutes to start up as it generates a world and prepares a spawn area. You will see a percentage as it goes.

launching minecraft server

(Image credit: Tom's Hardware)

Now your server should be running and you can log into it. However, if you ran the server from an SSH window, it will close the moment that you close the window (unless you put "nohup" before the server load command). And, even if you run it from a terminal window on the Pi (or via VNC), the server is not set to restart should you need to reboot the Raspberry Pi. 

Below, we'll show you how to create a script that will start the Minecraft server every time you boot the Raspberry Pi and should also restart the Minecraft server if it crashes but the Pi itself does not.

How to Start the Raspberry Pi Minecraft Server at Boot

1. Create a new file called mcstart.sh in the same folder as the server files (in our case, mcserver). You can create and open the file with nano.

nano mcstart.sh

2. Enter the following code to your bash script.

#!/bin/bash
cd ~/mcserver
while true
do
   java -Xmx1024M -Xms1024M -jar server.jar
   sleep 10
done

What we're doing here is changing to the directory where the server is and then running an endless loop that starts the server and then, if it ever stops, waits 10 seconds and starts it again. If the server never crashes, it will never get to the "sleep 10" part of the loop. 

If the path to your Minecraft server is something other than /mcserver on your Raspberry Pi, make sure to change that part of the script. 

3. Save and exit the file by hitting CTRL + X.

4. Set the mcstart.sh file to be executable by all users.

chmod a+x mcstart.sh

So now you can just the mcstart command from the command line, but that won't do you much good unless the system runs it automatically at boot. 

5. Open the crontab editor.

crontab -e

If this is the first time  you've opened crontab on this Raspberry Pi, you'll be asked to select an editor. Select nano if given a choice.

6. Enter @reboot and the path to mcstart.sh at the bottom of the crontab file and save it by hitting CTRL + X. In our case, the line looked like this but yours may vary based on the path to your home directory and what you named your server directory.

@reboot /home/pi/mcserver/mcstart.sh

7. Reboot your raspberry pi and see if it works.

How to Put Raspberry Minecraft Server on the Internet

If you've installed a Minecraft server on your Raspberry Pi and configured it to run every time you boot up, you and anyone on your local network can now log into it. However, unless everyone you want to play with is in your home,  you'll want to make that server available on the Internet.

1. Configure the Raspberry Pi to use a static IP address. If you don't know how to do this, see our tutorial on how to make Raspberry Pi use a static IP address. A static IP benefits you, because you want to make sure that its local IP v4 number is the same even if you reboot it.

Configuring your Pi to use a static IP

(Image credit: Future)

2. Set a port forwarding rule on your router that forwards port 25565 to your Raspberry Pi Minecraft server's internal IP address. The process will differ slightly on each router. You need to get into the admin panel, look for the port forwarding menu and then create a rule. 

Forward port 25565 to your Minecraft server

(Image credit: Future)

3. Determine your public IP v4 address. The easiest way is to navigate to whatismyipaddress.com. Googling "what is my ip address" usually works, but sometimes you just get the IP v6 address that way. 

Screen shot from whatismyipaddress.com

(Image credit: Future)

You can now give this address out to your friends and they can use it to log into your server. However, unless you are paying your ISP extra for a fixed IP address, you can't count on this IP address staying the same. If you unplug your modem, lose power temporarily or experience anything that takes your home offline, you may have a different IP when you come back on and have to look it up again.

If you are satisfied with giving out the IP address to your friends every time they want to log on, you can stop here. Otherwise, consider the next step.

4. Use No-IP, a dynamic DNS service, to create a hostname that directs traffic straight to whatever your current home IP address is. The service has a free tier you can sign up for on noip.com The company also has Instructions for installing the relevant software on your Pi .

Logging into a Raspberry Pi Minecraft Server

1. Launch Minecraft Java edition on the computer you wish to play from.

2. Select Multiplayer.

select multiplayer

(Image credit: Tom's Hardware)

3. Click Add Server.

click add server

(Image credit: Tom's Hardware)

5. Enter the server's hostname or IP address and give it a name (or leave it as "A Minecraft Server." That name is just for your benefit. Click Done when done. 

enter server address

(Image credit: Tom's Hardware)

The server will appear on your list of servers. 

6. Click the icon for the server to enter it.

click the icon to enter

(Image credit: Tom's Hardware)

And that should get you in and playing on your local Raspberry Pi Minecraft server. 

Avram Piltch
Avram Piltch is Tom's Hardware's editor-in-chief. When he's not playing with the latest gadgets at work or putting on VR helmets at trade shows, you'll find him rooting his phone, taking apart his PC or coding plugins. With his technical knowledge and passion for testing, Avram developed many real-world benchmarks, including our laptop battery test.
  • Stuck in the Loop
    Your readers should be aware that the ability to run a server on a home ISP account is becoming more rare. Many specifically ban running servers and more and more are converting to CGNAT where you share your incoming IP with other users. If you have free access to your server, using ngrok might get you past this.
    Reply
  • Howardohyea
    Raspberry Pi OS is very light, it doesn't use more than a gig, so I'd recommend allocating all of your RAM except one gig to Minecraft. You need all the performance you can get on the Pi.

    Furthermore, also get Lithium on the Pi to optimize the server. It requires Fabric though.

    Edit: If anyone's curious, I wrote my own setup guide here, which covered some workarounds for issues I encountered following the article, server configuration, and also installing mods.
    Reply
  • EagleHunter
    Is there a way to use an already existing server and transfer it to your pi?
    Reply
  • Howardohyea
    EagleHunter said:
    Is there a way to use an already existing server and transfer it to your pi?
    easiest way I can think of is simply copying the world save over to your Pi from your PC, it shouldn’t pose too much issues.
    Reply