On this page
This walks through a working Paper server on a fresh Debian or Ubuntu machine: the right Java version, a dedicated user to run it as, the server itself, and a service that starts it on boot.
Everything below is run over SSH. If you have not connected to your server yet, start with Connecting to your server.
Which Java version to install
Each Minecraft version sets a minimum Java version. Installing something older means the server refuses to start.
| Minecraft version | Minimum Java |
|---|---|
| 1.16.5 and older | Java 8 |
| 1.17.x | Java 16 |
| 1.18 to 1.20.4 | Java 17 |
| 1.20.5 and newer | Java 21 |
Paper runs on a newer Java than its minimum, so for any current Paper build, installing Java 21 and moving on is the right answer. Fabric and Forge modpacks are fussier: use the Java version the pack itself states, because a pack built for Java 17 can fail on 21.
How to check you got it right. Start the server. If Java is too old it stops
immediately and prints the version it needs, or throws
UnsupportedClassVersionError with a class file version number. Neither is
subtle. To see what you currently have:
java -versionInstalling
Update the system and install Java
On Debian or Ubuntu:
sudo apt update sudo apt install -y openjdk-21-jre-headless java -versionThe headless JRE is all a server needs. You only want the JDK if you intend to compile plugins on the machine.
If that package is not found, your release does not carry it. See what it does have:
apt-cache search '^openjdk-' | grep jre-headlessIf the version you need is missing, enable backports for your Debian release, or install a Temurin build from Adoptium, who publish packages and tarballs for every current Java release.
On Alma, Rocky, or RHEL the equivalent is:
sudo dnf install -y java-21-openjdk-headlessCreate a user for the server
sudo adduser --disabled-password --gecos "" minecraftThis creates the user
minecraftwith a home directory and a normal shell, but no password, so nobody can sign in as it directly. You reach it from your own account withsudo. On Alma, Rocky, or RHEL usesudo useradd -m minecraftinstead.Switch to it:
sudo -iu minecraftMake a directory for the server
As the
minecraftuser:mkdir -p ~/server && cd ~/serverEverything the server writes stays inside this folder: the world, the config, the logs, and the plugins.
Download Paper
Open papermc.io in a browser, choose your Minecraft version, and copy the download link for the latest build. Then, on the server:
wget -O paper.jar 'PASTE_THE_DOWNLOAD_URL_HERE'Save it as
paper.jarrather than the versioned filename. The service file below then never has to change when you update, and you can keep the previous jar alongside it to roll back to.Accept the EULA
Run the server once. It will stop straight away:
java -Xms2G -Xmx2G -jar paper.jar --noguiIt writes
eula.txtand exits with a message telling you to agree to Mojang's EULA. Read it, then set the flag:sed -i 's/eula=false/eula=true/' eula.txtThe
-Xmsand-Xmxvalues are the Java heap, set here to a plain starting point. Sizing them properly is covered in Optimising a Minecraft server.First real run
Run the same command again:
java -Xms2G -Xmx2G -jar paper.jar --noguiIt generates the world and the config files, which takes a minute or two, and finishes with a
Doneline and a console prompt. Typestopand press enter to shut it down cleanly. Never kill it with Ctrl-C part way through a save if you can avoid it.You now have
server.properties, aworldfolder, apluginsfolder, andlogs/latest.log.Set the basics in server.properties
Open
server.propertiesin an editor. The ones worth setting before you go live:Setting What to do with it server-portLeave at 25565 unless you have a reason. Whatever you set here is the port you must open. online-modeLeave true. This is what verifies joining accounts against Mojang, and it is the single biggest anti-bot control you have. See Protecting a Minecraft server from attacks.max-playersSet it to what your machine and your heap can actually hold, not to an aspiration. motdThe line shown in the client's server list. view-distanceandsimulation-distanceThe two highest-impact performance settings. Covered in Optimising a Minecraft server. white-listSet truefor a private server, and add names with/whitelist add.The server reads this file at startup, so restart after editing it.
Keeping it running
Closing your SSH session kills anything you started in it. You need the server to survive that, and to come back after a reboot.
Under systemd
This is the option to take for anything you care about. Leave the minecraft
user first:
exitCreate the unit file:
sudo nano /etc/systemd/system/minecraft.service[Unit]
Description=Minecraft server
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=minecraft
Group=minecraft
WorkingDirectory=/home/minecraft/server
ExecStart=/usr/bin/java -Xms2G -Xmx2G -jar paper.jar --nogui
Restart=on-failure
RestartSec=10s
TimeoutStopSec=120
SuccessExitStatus=0 143
[Install]
WantedBy=multi-user.targetSuccessExitStatus=0 143 tells systemd that exiting on SIGTERM is a normal stop,
not a crash, so Restart=on-failure does not fight you. TimeoutStopSec=120
gives the server time to save the world before systemd loses patience: the
Minecraft server handles SIGTERM by saving and shutting down, and a large world
does not do that instantly.
Enable and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now minecraft
sudo systemctl status minecraftWatch the log live:
sudo journalctl -u minecraft -fStop and start it with sudo systemctl stop minecraft and
sudo systemctl start minecraft. Because the console is not attached to a
terminal, you cannot type commands into it this way. Use RCON over an SSH tunnel,
or an in-game admin plugin, or run under tmux instead.
Under tmux
Simpler, and it gives you the console back, but it does not restart the server after a crash or a reboot.
sudo apt install -y tmux
sudo -iu minecraft
cd ~/server
tmux new -s mc
java -Xms2G -Xmx2G -jar paper.jar --noguiDetach with Ctrl-b then d, and the server keeps running. Come back to it with:
sudo -iu minecraft
tmux attach -t mcUse tmux while you are setting things up, and move to systemd before players arrive.
Opening the port
The server is listening, but nothing can reach it until the port is open.
On a Clouduxe server, apply the Minecraft (Java) preset, which writes the
TCP 25565 rule for you, or add the rule by hand if you changed server-port. See
Game presets and
Port rules.
If you also run a firewall on the machine itself, allow the port there too:
sudo ufw allow 25565/tcpTesting the connection
In the Java client, open Multiplayer, press Add Server, and enter your server's IP address. You do not need to type the port if it is 25565.
If it does not connect, work through
When players cannot connect,
and check sudo journalctl -u minecraft -f at the same time so you can see
whether the connection is reaching the server at all.
Back it up before you change anything
Copy the world before your first plugin, your first config change, and every update after that. Stop the server first, or you will copy a region file that was half-written when you started.
sudo systemctl stop minecraft
sudo -iu minecraft
tar czf ~/world-backup-$(date +%F).tar.gz -C ~/server world world_nether world_the_endSee Backups for keeping a copy somewhere other than the machine that is running the server, which is the only kind of backup that helps when the machine is the problem.
Related
Java or Bedrock, which server software to run, and what the machine needs.
Optimising a Minecraft serverHeap sizing, Aikar's flags, view distance, and finding a laggy plugin.
Installing and managing Minecraft pluginsAdding your first plugin without breaking the server.
Protecting a Minecraft server from attacksWhat to set before the server is publicly reachable.