How to create a Minecraft server on VPS Ubuntu
A VPS allows you to run a Minecraft Java Edition server with control over files, memory, plugins and settings. This tutorial shows the basic installation on Ubuntu.
Requirements
- VPS Ubuntu 22.04 or 24.04;
- SSH access;
- memory appropriate to the version and number of players;
- official Minecraft server file;
- port 25565 released.
1. Update Ubuntu
sudo apt update
sudo apt upgrade -y
2. Install Java
Recent versions of Minecraft Java Edition use Java 21:
sudo apt install -y openjdk-21-jre-headless wget
java -version
Before using an older version of Minecraft, confirm which version of Java it requires.
3. Create a separate user
sudo adduser --system --home /opt/minecraft --group minecraft
sudo mkdir -p /opt/minecraft
sudo chown -R minecraft:minecraft /opt/minecraft
Running the game under your own account reduces the impact of a possible crash.
4. Download the official server
Open the Minecraft Java Edition server download page, copy the current address of the server.jar file and run:
sudo -u minecraft wget "URL_DO_SERVER_JAR" -O /opt/minecraft/server.jar
Replace URL_DO_SERVER_JAR with the link copied from the official page.
Check it out:
ls -lh /opt/minecraft/server.jar
5. Run for the first time
Adjust memory according to available resources:
cd /opt/minecraft
sudo -u minecraft java -Xms1G -Xmx2G -jar server.jar nogui
The first run creates the files and stops because the EULA has not yet been accepted.
6. Accept the EULA
Read the terms indicated in the file and edit:
sudo nano /opt/minecraft/eula.txt
Change:
eula=false
For:
eula=true
Save only if you agree to the EULA.
7. Start the server
cd /opt/minecraft
sudo -u minecraft java -Xms1G -Xmx2G -jar server.jar nogui
Use stop on the console to shut down correctly. Do not forcefully end the process while saving the world.
8. Release the default port
sudo ufw allow 25565/tcp
sudo ufw status
Players can connect using:
IP_DA_VPS:25565
Memory adjustment
- Xms defines the initial memory;
- Xmx defines the maximum limit;
- do not reserve all RAM for Minecraft;
- leave memory for Ubuntu, Java, backups and other services.
Frequently asked questions
Why does the server close when starting?
Verify that the EULA has been accepted, that Java is supported, that the JAR file has finished downloading, and that memory is available.
How to change the game mode and difficulty?
Stop the server and edit /opt/minecraft/server.properties. Then start again.
How to reduce lag in Minecraft?
Monitor CPU, memory, disk, number of entities, rendering distance and plugins. Also check out latency and packet loss on VPS Gamer.
Do I need to release UDP 25565?
The default Java server uses TCP 25565. Additional software may require other ports; consult the documentation used.
If you need help with VPS Gamer, open a ticket with Nice Hosting support.