Creating a Minecraft server (Java Edition, Paper and vanilla)
Here's how to install a Minecraft Java Edition server on an Ubuntu server and play on it with your friends.
Before you start
- Specs: For a few friends playing vanilla, we recommend 4GB of memory or more; if you use lots of mods/plugins or have many players, 8GB or more. How to choose VPS specs (recommended specs by use case)
- Network: If your server will be open to the public, consider the Security Zone to be ready for DDoS attacks. The Security Zone bills traffic for the amount you use, so check traffic usage too.
1. Install Java
The latest Minecraft (1.21 and above) needs Java 21.
sudo apt update
sudo apt install -y openjdk-21-jre-headless screen
java -version
2. Download the server file
Create a folder for the server and download the server executable (.jar).
- Vanilla (official): Copy the
server.jarlink from the "Minecraft: Java Edition server download" page on minecraft.net. - Paper (supports plugins, lighter): Copy the link for the version you want from the download page on papermc.io.
mkdir ~/minecraft && cd ~/minecraft
wget -O server.jar "copied download link"
3. First run and agreeing to the EULA
java -Xms1G -Xmx3G -jar server.jar nogui
On the first run, it exits right away and creates an eula.txt file. Change it to the setting that agrees to Minecraft's terms of use.
sed -i 's/eula=false/eula=true/' eula.txt
-Xmx3Gis the maximum memory given to the server. Set it leaving 1–2GB of the server's total memory for the operating system. (e.g., 4GB server →-Xmx3G, 8GB server →-Xmx6G)
4. Keep it running after closing the window (screen)
Closing the SSH window shuts the server down too, so run it inside screen.
screen -S mc
java -Xms1G -Xmx3G -jar server.jar nogui
- Leave while keeping the server running: press
Ctrl + A, thenD - Go back to the server console:
screen -r mc - Stop the server: type
stopin the server console
5. Open the firewall
If you've turned on the firewall (ufw), open the Minecraft port. (Opening firewall ports)
sudo ufw allow 25565/tcp
6. Connect
In Minecraft → Multiplayer → Add Server, enter the server IP as the Server Address. If you're using the default port (25565), you can leave the port out.
Common problems
- I can't connect — Check that
Done (...)! For help, type "help"has appeared in the server console, and that 25565 is open in the firewall. - It's really laggy — Increase the
-Xmxmemory, switch to a Paper server, or consider a plan with higher specs. - The server suddenly shut down — It may have been forcibly shut down because it ran out of memory. Check that you set
-Xmxlower than the server's memory. - World backups — With the server stopped, download the
worldfolder to your PC. Uploading and downloading files