Setting up your own Minecraft server takes 20-60 minutes and costs $5-60 monthly, depending on your player count. You get complete control over your gaming experience, choose your own mods, and create the exact world you want.
This guide covers self-hosting on a VPS or cloud server with optimized performance and proper security. We'll show you production-ready configurations used by professional server hosts, with step-by-step instructions for security hardening, performance tuning, and automated maintenance.
Hosting options explained
Self-hosting on your PC
Running the server on your computer gives you immediate access without monthly fees. Your PC must remain running at all times, which can lead to higher electricity costs and performance issues when multitasking. Security becomes your responsibility entirely.
Self-hosting on a VPS or cloud server
A VPS is a remote computer you rent that runs independently from your home setup. Unlike shared hosting, you get dedicated resources and full control over the server software.
VPS plans suitable for Minecraft start at $5-8/month for 1-10 players. Key features to look for:
- Dedicated CPU cores (not shared vCPU)
- NVMe SSD storage (3-5x faster than SATA)
- Unmetered bandwidth (2-3 Mbps per player minimum)
- Full root access (required for this guide)
- Snapshots/backups (critical for world protection)
Your server stays online continuously without relying on your personal computer. Players can connect anytime, and your home internet doesn't affect server performance. You can scale resources up or down based on player count without buying new hardware.
Renting a managed server
Managed hosting providers offer one-click setups but cost $15-60+/month with less customization.
Hosting cost comparison
| Hosting type | Cost inputs | Capacity test | Operational review |
|---|---|---|---|
| Home PC | Hardware already owned, measured electricity, network changes, backup power | Test the target version, mods, player simulation, and upload path | Local power, ISP, router, security, monitoring, backup, and recovery |
| VPS | Current plan, transfer, backups, support, and operations time | Benchmark the selected plan and region with the target server build | Hardening, patching, monitoring, backup restore, and resize path |
| Managed Minecraft host | Current tier, player or resource limits, add-ons, backups, and renewal terms | Test the exact tier with the target mods and player profile | Confirm control-panel limits, support scope, export, restore, and cancellation |
| Dedicated server | Current hardware quote, setup, transfer, support, and operations time | Benchmark the selected hardware and network | Provisioning lead time, remote console, replacement, backup, and recovery |
Minimum requirements for self-hosting
CPU: Modern quad-core (Intel i3-13100 or AMD Ryzen 5 7600). Single-core speed matters most for Minecraft's single-threaded world simulation. ARM-based cloud instances (AWS Graviton, Oracle Ampere) provide excellent price-to-performance but may have compatibility issues with some plugins.
RAM: Allocate based on your server type:
- 4GB: Vanilla (1-10 players)
- 6-8GB: Light mods/plugins (10-20 players)
- 12GB+: Heavy modpacks (20+ players)
- Always reserve 2GB for OS overhead
Storage: NVMe SSD strongly recommended for 20+ players or worlds >5GB. SATA SSD minimum. Never use HDD because world loading will create unacceptable lag. Budget 10-20GB for the server, plus 5-10GB per 1000 chunks of world generation.
Network: 2-3 Mbps upload per player minimum for Minecraft 1.20 and above. For 10 concurrent players, expect 20-30 Mbps sustained usage. Under 50ms latency is ideal; test your connection to the datacenter before committing to a provider.
OS: Ubuntu Server 24.04 LTS or Debian 12 recommended (lower resource usage than Windows Server, free, and better documented for Minecraft).
Server setup
Preparing your environment
Secure your server
Connect to your VPS using SSH:
“`bash title="Connect to the VPS as root" ssh root@yourserverip
Create a non-root user:
```bash title="Create a sudo-enabled minecraft user"
adduser minecraft
usermod -aG sudo minecraft
Set up SSH keys (more secure than passwords):
“`bash title="Generate and install an SSH key for minecraft" ssh-keygen -t ed25519 -C "minecraft-server" ssh-copy-id minecraft@yourserverip
Test the new account in a second terminal:
```bash title="Connect to the VPS as minecraft"
ssh minecraft@your_server_ip
Disable root login:
“`bash title="Edit the OpenSSH server configuration" sudo nano /etc/ssh/sshd_config
Change these lines:
```conf title="Disable root login and password authentication"
PermitRootLogin no
PasswordAuthentication no
Restart SSH:
“`bash title="Restart the OpenSSH daemon" sudo systemctl restart sshd
Test your sudo user login in a second terminal before logging out of root.
#### System updates and essential packages
Update all packages:
```bash title="Update Ubuntu packages and reboot"
sudo apt update
sudo apt upgrade -y
sudo reboot
Wait two minutes, then reconnect. Set timezone for consistent logs:
“`bash title="Set the server timezone to UTC" sudo timedatectl set-timezone UTC
Install required packages:
```bash title="Install Minecraft administration tools"
sudo apt install screen wget curl jq ufw fail2ban unattended-upgrades pigz -y
Firewall configuration
Configure UFW:
“`bash title="Configure UFW for SSH and Minecraft" sudo ufw default deny incoming sudo ufw default allow outgoing sudo ufw allow 22/tcp comment 'SSH' sudo ufw limit 25565/tcp comment 'Minecraft' sudo ufw enable
The limit rule provides rate-limiting protection against connection floods and automatically applies to both IPv4 and IPv6.
**Note:** If adding other services later (web panel, voice chat), you'll need to allow their ports.
Verify status:
```bash title="Show detailed UFW status"
sudo ufw status verbose
Automated security
Enable automatic security updates:
“`bash title="Configure unattended Ubuntu upgrades" sudo dpkg-reconfigure -plow unattended-upgrades
Select "Yes" when prompted.
Enable fail2ban:
```bash title="Enable and start Fail2Ban"
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
Installing Java
Minecraft requires Java to run. Different versions need specific Java versions.
| Minecraft version | Required Java |
|---|---|
| 1.21.x | Java 21 LTS or Java 23+ |
| 1.20.5-1.20.6 | Java 21 LTS |
| 1.20.1-1.20.4 | Java 17 LTS |
| 1.18-1.19.x | Java 17 LTS |
| 1.17.x | Java 16 |
| 1.12-1.16.5 | Java 8 |
Install Java 21:
“`bash title="Install the Java 21 headless runtime" sudo apt install openjdk-21-jre-headless -y
Verify installation:
```bash title="Show the installed Java version"
java -version
For older Minecraft versions, install openjdk-17-jre-headless or openjdk-8-jre-headless instead.
Note: Java 21 LTS is the current standard for Minecraft 1.21.x servers. Java 23 is also supported and stable, but Java 21 is recommended for long-term stability. Never use Java 22 as it is a non-LTS release.
Downloading server software
Different server software offers different features and performance.
Server software options
- Vanilla: Official Mojang server software. Pure vanilla experience, baseline performance.
- Paper (recommended): 40-80% better performance than vanilla plus plugin support. Most public servers use Paper.
- Folia: Paper's multi-threaded fork. Best for 100+ player servers with compatible plugins.
- Purpur: Popular Paper fork with extra gameplay features and configuration options.
- Fabric: Mod support with performance similar to vanilla.
- Forge: Large mod ecosystem but heavier than Fabric; both support modern versions.
- Geyser/Floodgate: Allows Bedrock Edition players (mobile/console) to join Java servers. Download separately from Geyser and install in the plugins folder.
Creating server directory
“`bash title="Create and enter the Minecraft server directory" mkdir -p ~/minecraftserver cd ~/minecraftserver
#### Downloading server files
For Paper (recommended):
```bash title="Download the latest Paper build for Minecraft 1.21.10"
VERSION="1.21.10"
BUILD=$(curl -s "https://api.papermc.io/v2/projects/paper/versions/${VERSION}" | jq -r '.builds[-1]')
wget "https://api.papermc.io/v2/projects/paper/versions/${VERSION}/builds/${BUILD}/downloads/paper-${VERSION}-${BUILD}.jar" -O server.jar
Verify download:
“`bash title="Inspect the downloaded Paper server archive" ls -lh server.jar
You should see a file around 40-50MB.
### Creating an optimized start script
Create your start script:
```bash title="Edit the Minecraft start script"
nano start.sh
For servers with 4-6GB RAM (G1GC)
These flags are optimized for Java 21. If using different Java versions, consult the current JVM documentation.
“`bash title="Attempt to start Paper with G1GC tuning" #!/bin/bash java -Xms4G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -jar server.jar nogui
#### For servers with 8GB+ RAM (ZGC, recommended for Java 21+)
ZGC requires Java 17 or higher. Java 21 or newer is recommended for best performance.
```bash title="Attempt to start Paper with ZGC tuning"
#!/bin/bash
java -Xms8G -Xmx8G
-XX:+UseZGC
-XX:+ZGenerational
-XX:+DisableExplicitGC
-XX:+AlwaysPreTouch
-XX:+ParallelRefProcEnabled
-jar server.jar nogui
ZGC reduces lag spikes from 100+ milliseconds to under 1 millisecond on servers with 8GB+ RAM. ZGC uses 10-15% more RAM than G1GC but provides much smoother performance. Keep this memory overhead in mind when allocating RAM.
Note: ZGC is recommended for servers with consistent high player counts (15+ concurrent players). For smaller servers (1-10 players), G1GC with the above flags will provide excellent performance with lower memory overhead.
Note: Java 23 and newer enable ZGenerational by default, so the flag is optional for Java 23+. For Java 21 and 22, always include the ZGenerational flag for optimal performance.
For ZGC, keep Xms equal to Xmx because ZGC handles memory allocation differently and performs best with equal values. For G1GC on Java 21+, set Xms to 50-75% of Xmx. For Java 17 and below, set Xms equal to Xmx.
Never allocate more than 80% of your total system RAM.
Make the script executable:
“`bash title="Make the Minecraft start script executable" chmod +x start.sh
#### Accepting the EULA
Run your start script once:
```bash title="Run the Minecraft start script once"
./start.sh
The server creates files, then stops. Edit eula.txt:
“`bash title="Edit the Minecraft EULA file" nano eula.txt
Change `eula=false` to `eula=true` then save.
### Setting up as a system service
Create a service file:
```bash title="Create the Minecraft systemd unit file"
sudo nano /etc/systemd/system/minecraft.service
Add this configuration:
“`ini title="Define the Minecraft systemd service" [Unit] Description=Minecraft Server After=network.target [Service] Type=simple User=minecraft WorkingDirectory=/home/minecraft/minecraftserver ExecStart=/home/minecraft/minecraftserver/start.sh Restart=on-failure RestartSec=10 [Install] WantedBy=multi-user.target
Reload systemd and enable the service:
```bash title="Reload enable start and inspect Minecraft"
sudo systemctl daemon-reload
sudo systemctl enable minecraft
sudo systemctl start minecraft
sudo systemctl status minecraft
You should see "active (running)" in green.
Managing the service
View live logs:
“`bash title="Follow the Minecraft service journal" sudo journalctl -u minecraft -f
Restart the server:
```bash title="Restart the Minecraft service"
sudo systemctl restart minecraft
Stop the server:
“`bash title="Stop the Minecraft service" sudo systemctl stop minecraft
## Configuration
Stop the server first:
```bash title="Stop Minecraft before editing its configuration"
sudo systemctl stop minecraft
Edit server.properties:
“`bash title="Edit Minecraft server.properties" nano server.properties
Key settings:
```ini title="Configure Minecraft gameplay network and performance"
## Network
server-port=25565
max-players=20
## Gameplay
difficulty=normal
gamemode=survival
pvp=true
hardcore=false
enforce-secure-profile=true # Requires valid Mojang/Microsoft accounts
## Performance
view-distance=12
simulation-distance=8
network-compression-threshold=512
## Security
enable-command-block=false
white-list=false
Save changes and restart:
“`bash title="Start Minecraft after configuration changes" sudo systemctl start minecraft
### Paper configuration
Paper 1.20+ uses `config/paper-global.yml` and `config/paper-world-defaults.yml`. Default settings are highly optimized. For advanced tuning, see the [Paper configuration documentation](https://docs.papermc.io/paper/reference/configuration/).
Edit `spigot.yml` to reduce entity processing range:
```bash title="Edit the Paper spigot.yml configuration"
nano spigot.yml
Set entity-activation-range for animals and monsters to 48 and mob-spawn-range to 6.
Player management
Make operators in console:
“`text title="Grant operator status to one Minecraft player" op PlayerName
Enable whitelist:
```text title="Enable the whitelist and add one player"
whitelist on
whitelist add PlayerName
Network configuration
Port forwarding (home hosting only)
Access your router's admin panel at one of these common IPs: 192.168.1.1, 192.168.0.1, 10.0.0.1, or 192.168.2.1.
Create a port forwarding rule:
- Service Name: Minecraft
- External Port: 25565
- Internal Port: 25565
- Internal IP: Your server's local IP (find with ip addr)
- Protocol: TCP and UDP
For home hosting: Consider Dynamic DNS (DuckDNS, No-IP) if your ISP changes your IP regularly.
Testing your connection
Find your public IP:
“`bash title="Show the VPS public IP address" curl ifconfig.me
Check the port with the [MCToolBox port checker](https://mctoolbox.com/port-checker/).
### IPv6 configuration
Leave `server-ip=` blank in `server.properties` to auto-enable IPv4 and IPv6.
Verify IPv6 is listening:
```bash title="Check which process listens on port 25565"
sudo ss -tlnp | grep 25565
You should see entries showing both 0.0.0.0:25565 (IPv4) and :::25565 (IPv6).
Share your public IP with players to connect.
Connecting to your server
Launch Minecraft Java Edition. Ensure you're using the same version your server runs.
Click "Multiplayer" then "Add Server."
Enter:
- Server Name: Any name you choose
- Server Address: Your server's IP
Click "Done" to save. Green connection bars indicate success. Click the server to connect.
Need VPS resources for a Minecraft server?
Run Minecraft on Virtarix VPS infrastructure with root access, predictable CPU/RAM, NVMe storage, snapshots, backups, and room for players and worlds.
Troubleshooting
Connection timed out
Verify your firewall settings with sudo ufw status. Check if the server is running with sudo systemctl status minecraft. Test port accessibility with the MCToolBox port checker.
Wrong Java version
Error: Unsupported class file major version 65
Install Java 21:
“`bash title="Reinstall the Java 21 headless runtime" sudo apt install openjdk-21-jre-headless -y
### Out of memory
`java.lang.OutOfMemoryError: Java heap space`
Increase `Xmx` in `start.sh` or reduce player count.
### Performance issues
Check TPS in the console with `/tps` (20 = perfect, below 15 = lag).
Install Spark profiler for detailed analysis:
```bash title="Download the latest Spark profiler plugin"
mkdir -p ~/minecraft_server/plugins
cd ~/minecraft_server/plugins
wget https://ci.lucko.me/job/spark/lastSuccessfulBuild/artifact/spark-bukkit/build/libs/spark-bukkit.jar
Restart the server, then use /spark profiler in-game.
For advanced ZGC performance monitoring, add this to your start script:
“`text title="Enable rotating JVM garbage-collection logs" -Xlog:gc*:file=gc.log:time,uptime:filecount=5,filesize=10M
## Maintenance
### Automated backup system
Create a backup script:
```bash title="Edit the Minecraft backup script"
nano ~/backup-minecraft.sh
Add:
“`bash title="Back up Minecraft worlds and rotate old archives" #!/bin/bash SERVERDIR="/home/minecraft/minecraftserver" BACKUPDIR="/home/minecraft/backups" MAXBACKUPS=7 mkdir -p "$BACKUPDIR" if systemctl is-active –quiet minecraft; then sudo systemctl stop minecraft sleep 5 fi DATE=$(date +%Y-%m-%d%H-%M-%S) BACKUPFILE="$BACKUPDIR/backup$DATE.tar.gz" if command -v pigz &> /dev/null; then tar -cf – -C "$SERVERDIR" world worldnether worldtheend server.properties ops.json whitelist.json | pigz > "$BACKUPFILE" else tar -czf "$BACKUPFILE" -C "$SERVERDIR" world worldnether worldtheend server.properties ops.json whitelist.json fi sudo systemctl start minecraft find "$BACKUPDIR" -name "backup*.tar.gz" -mtime +$MAXBACKUPS -delete echo "$DATE – Backup created: $BACKUPFILE ($(du -h "$BACKUPFILE" | cut -f1))" >> "$BACKUP_DIR/backup.log"
Make executable:
```bash title="Make the Minecraft backup script executable"
chmod +x ~/backup-minecraft.sh
Schedule daily backups:
“`bash title="Edit the current user's crontab" crontab -e
Add:
```text title="Schedule the Minecraft backup for 04:00 daily"
0 4 * * * /home/minecraft/backup-minecraft.sh
Adjust MAX_BACKUPS based on backup frequency (7 for daily, 4 for weekly).
Restoring from backup
Stop server:
“`bash title="Stop Minecraft before restoring a backup" sudo systemctl stop minecraft
Extract backup:
```bash title="Extract a Minecraft backup over the server directory"
cd ~/minecraft_server
tar -xzf ~/backups/backup_YYYY-MM-DD_HH-MM-SS.tar.gz
Start server:
“`bash title="Start Minecraft after a restore" sudo systemctl start minecraft
### Server updates
Stop the server:
```bash title="Stop Minecraft before updating Paper"
sudo systemctl stop minecraft
Backup current version:
“`bash title="Back up the current Paper server JAR" cp ~/minecraftserver/server.jar ~/minecraftserver/server.jar.backup
Check plugin compatibility in the [Paper downloads](https://papermc.io/downloads) before major version updates.
Download new version:
```bash title="Download the latest Paper build for Minecraft 1.21.10"
cd ~/minecraft_server
VERSION="1.21.10"
BUILD=$(curl -s "https://api.papermc.io/v2/projects/paper/versions/${VERSION}" | jq -r '.builds[-1]')
wget "https://api.papermc.io/v2/projects/paper/versions/${VERSION}/builds/${BUILD}/downloads/paper-${VERSION}-${BUILD}.jar" -O server.jar
Start the server:
“`bash title="Start Minecraft after the Paper update" sudo systemctl start minecraft
Monitor for errors:
```bash title="Follow Minecraft logs after updating Paper"
sudo journalctl -u minecraft -f
If problems occur, restore the backup:
“`bash title="Restore the previous Paper JAR and restart Minecraft" cp ~/minecraftserver/server.jar.backup ~/minecraftserver/server.jar sudo systemctl restart minecraft
### Regular maintenance
Run weekly:
```bash title="Update Ubuntu and review disk space and Minecraft errors"
sudo apt update && sudo apt upgrade # System updates
df -h # Check disk space
sudo journalctl -u minecraft --since "7 days ago" | grep ERROR # Check errors
Verify automatic updates are working:
“`bash title="Show the unattended-upgrades service status" sudo systemctl status unattended-upgrades
## Conclusion
You now have a production-ready Minecraft server with optimized JVM settings, automated backups, and proper security. Keep your server updated for security and performance. Monitor resource usage through logs and address performance issues before they affect players.
Install plugins from [Hangar](https://hangar.papermc.io/) or [Modrinth](https://modrinth.com/) to extend functionality. Start with friends, learn the systems, then expand as you gain experience.
Ready to host a Minecraft server on Virtarix VPS?
Compare VPS sizes for Minecraft servers with predictable CPU/RAM, NVMe storage, IPv4 + IPv6, root access, snapshots, and backups.
VPS S
For small sites, dev servers and Docker
- ✓ 3 cores
- ✓ 6 GB
- ✓ 50 GB NVMe
- ✓ Unlimited
VPS M
For growing apps, websites and staging
- ✓ 6 cores
- ✓ 16 GB
- ✓ 100 GB NVMe
- ✓ Unlimited