How to Set Up a Game Server on a VPS: Minecraft, CS2 & Valheim

How to Set Up a Game Server on a VPS: Minecraft, CS2 & Valheim

Tired of relying on someone else’s server with random lag spikes, unexpected downtime, and rules you didn’t agree to? Running a game server on your own VPS gives you full control — 24/7 uptime, custom mods, whitelisted players, and performance tuned exactly to your needs.

In this guide, we’ll walk through setting up three of the most popular self-hosted game servers in 2025: Minecraft Java Edition, Counter-Strike 2 (CS2), and Valheim. All setups are on Ubuntu, and each section is fully self-contained — jump straight to the game you need.

Why Host a Game Server on a VPS?

  • Always online — Unlike home hosting, your VPS runs 24/7 without consuming your own electricity or internet bandwidth.
  • Low latency — Choose a data center close to your players for consistently low ping.
  • Full root access — Install any mods, plugins, or custom configurations without restrictions.
  • Scalable — Start small and upgrade RAM/CPU as your player count grows.
  • Private and secure — Whitelist only your friends, set custom passwords, and ban griefers permanently.

Choosing the Right VPS for Gaming

Game servers are CPU and RAM intensive. Before picking a plan, here are the minimum and recommended specs per game:

Game Min RAM Recommended RAM CPU Storage
Minecraft (vanilla, 10 players) 2 GB 4 GB 2 vCPU 20 GB SSD
Minecraft (modded, 20+ players) 4 GB 8 GB 4 vCPU 40 GB SSD
CS2 (10-player competitive) 2 GB 4 GB 2 vCPU 30 GB SSD
Valheim (up to 10 players) 2 GB 4 GB 2 vCPU 20 GB SSD

💡 VPS.DO Recommendation: The USA VPS 500SSD plan (2 vCPU, 4 GB RAM, 500 GB SSD, 1 Gbps port) handles all three games comfortably for small friend groups. For larger communities or modded Minecraft, consider a 8 GB RAM plan.


Part 1: Minecraft Java Edition Server on a VPS

Minecraft remains one of the most popular self-hosted games worldwide. The Java Edition server runs natively on Linux and is easy to set up.

Step 1: Update and Install Java

sudo apt update && sudo apt upgrade -y
sudo apt install openjdk-21-jre-headless screen -y

Verify Java is installed:

java -version

Step 2: Create a Dedicated User and Directory

Always run game servers as a non-root user for security:

sudo useradd -m -s /bin/bash minecraft
sudo su - minecraft
mkdir ~/server && cd ~/server

Step 3: Download the Minecraft Server JAR

Get the latest server version from minecraft.net and copy the direct download link. Example for 1.21:

wget https://piston-data.mojang.com/v1/objects/[latest-hash]/server.jar -O server.jar

Or use curl to fetch it:

curl -o server.jar https://piston-data.mojang.com/v1/objects/[latest-hash]/server.jar

Step 4: Accept the EULA

Run the server once to generate config files:

java -Xmx1024M -Xms1024M -jar server.jar nogui

It will stop and ask you to accept the EULA. Edit the file:

nano eula.txt

Change eula=false to eula=true, save and exit.

Step 5: Configure the Server

nano server.properties

Key settings to adjust:

# Server name shown in multiplayer list
motd=My VPS.DO Minecraft Server

# Max players
max-players=20

# Set a password (empty = no password)
online-mode=true

# World difficulty
difficulty=normal

# Enable whitelist (recommended)
white-list=true

Step 6: Start the Server Inside a Screen Session

Use screen so the server keeps running after you disconnect from SSH:

screen -S minecraft
java -Xmx3G -Xms1G -jar server.jar nogui

Detach from the screen session without stopping the server: Ctrl+A then D

Re-attach later:

screen -r minecraft

Step 7: Open the Firewall Port

Switch back to your sudo user and open the Minecraft port:

exit  # back to sudo user
sudo ufw allow 25565/tcp

Step 8: Connect to Your Server

In Minecraft, go to Multiplayer → Add Server and enter your VPS IP address. Your server should appear online. ✅

Bonus: Auto-Start on Reboot

Create a systemd service to auto-start the Minecraft server:

sudo nano /etc/systemd/system/minecraft.service
[Unit]
Description=Minecraft Server
After=network.target

[Service]
User=minecraft
WorkingDirectory=/home/minecraft/server
ExecStart=/usr/bin/java -Xmx3G -Xms1G -jar server.jar nogui
Restart=on-failure

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable minecraft
sudo systemctl start minecraft

Part 2: Counter-Strike 2 (CS2) Dedicated Server on a VPS

CS2 dedicated servers use Valve’s SteamCMD tool. The process is straightforward once SteamCMD is installed.

Step 1: Install Dependencies

sudo apt update && sudo apt upgrade -y
sudo apt install lib32gcc-s1 screen curl -y

For 64-bit systems, enable 32-bit libraries:

sudo dpkg --add-architecture i386
sudo apt update
sudo apt install lib32gcc-s1 -y

Step 2: Create a Steam User

sudo useradd -m -s /bin/bash steam
sudo su - steam

Step 3: Install SteamCMD

mkdir ~/steamcmd && cd ~/steamcmd
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -

Step 4: Download CS2 Server Files

./steamcmd.sh +force_install_dir ~/cs2-server +login anonymous +app_update 730 validate +quit

This downloads approximately 25–30 GB of CS2 server files. It may take 10–30 minutes depending on your VPS network speed.

Step 5: Get a Game Server Login Token (GSLT)

CS2 requires a free Game Server Login Token to list your server publicly. Get one at steamcommunity.com/dev/managegameservers (App ID: 730).

Step 6: Start the CS2 Server

screen -S cs2
cd ~/cs2-server
./game/bin/linuxsteamrt64/cs2 \
  -dedicated \
  -console \
  -usercon \
  +sv_setsteamaccount YOUR_GSLT_TOKEN \
  +map de_dust2 \
  +game_type 0 \
  +game_mode 1 \
  +sv_lan 0

Detach: Ctrl+A then D

Step 7: Open Firewall Ports

exit  # back to sudo user
sudo ufw allow 27015/tcp
sudo ufw allow 27015/udp
sudo ufw allow 27020/udp

Step 8: Connect to Your Server

In CS2, open the developer console and type:

connect YOUR_VPS_IP:27015

✅ Your CS2 dedicated server is live.


Part 3: Valheim Dedicated Server on a VPS

Valheim is a Viking survival game with an excellent dedicated server option. It’s lighter on resources than Minecraft or CS2 and runs very smoothly on a modest VPS.

Step 1: Install Dependencies and SteamCMD

sudo apt update && sudo apt upgrade -y
sudo apt install lib32gcc-s1 screen -y
sudo useradd -m -s /bin/bash valheim
sudo su - valheim
mkdir ~/steamcmd && cd ~/steamcmd
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -

Step 2: Download Valheim Server Files

./steamcmd.sh +force_install_dir ~/valheim-server +login anonymous +app_update 896660 validate +quit

Step 3: Create the Start Script

cd ~/valheim-server
nano start_server.sh

Paste the following (replace the values in caps with your own):

#!/bin/bash
export templdpath=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
export SteamAppId=892970

echo "Starting Valheim server..."

./valheim_server.x86_64 \
  -name "MY VALHEIM SERVER" \
  -port 2456 \
  -world "MyWorld" \
  -password "YOURPASSWORD" \
  -public 1

export LD_LIBRARY_PATH=$templdpath

Make it executable:

chmod +x start_server.sh

Step 4: Start the Valheim Server

screen -S valheim
./start_server.sh

Detach: Ctrl+A then D

Step 5: Open Firewall Ports

exit  # back to sudo user
sudo ufw allow 2456/udp
sudo ufw allow 2457/udp

Step 6: Connect in Valheim

In Valheim, go to Join Game → Add Server and enter YOUR_VPS_IP:2456. Enter the password when prompted.

✅ Your Valheim server is ready for Viking raids.


General Game Server Tips

Use tmux instead of screen (optional)

If you prefer a more modern terminal multiplexer, tmux offers split panes and better session management. Install it with sudo apt install tmux.

Set up automatic backups

Game world data is precious. Back up your world files daily with a simple cron job:

crontab -e
# Daily backup at 3 AM
0 3 * * * tar -czf ~/backups/world-$(date +\%F).tar.gz ~/server/world

Monitor resource usage

Keep an eye on RAM and CPU so you can upgrade before performance degrades:

htop

Keep server software updated

For Minecraft, check for new server JARs regularly. For CS2 and Valheim, re-run SteamCMD’s app_update command to pull patches.

Protect SSH

A publicly accessible VPS running game servers is a target for brute-force SSH attacks. Use key-based SSH authentication and disable password logins.


Troubleshooting Common Issues

Server starts but friends can’t connect

Check that the correct UDP/TCP ports are open with sudo ufw status and confirm your VPS firewall (in the VPS.DO control panel, if applicable) also allows those ports.

Server crashes after a few minutes

Usually an out-of-memory (OOM) issue. Check free memory with free -h and either reduce the max player count, lower the Java heap allocation, or upgrade to a higher RAM plan.

High ping for players

Choose a VPS data center geographically close to your player base. VPS.DO offers USA (Los Angeles) and Hong Kong locations — ideal for North American and Asia-Pacific players respectively.

SteamCMD download fails

Steam’s CDN can occasionally be slow. Try running the download command again — SteamCMD resumes from where it left off.


Which VPS Plan Should You Choose?

For most gaming use cases, VPS.DO’s entry-level plans are more than sufficient for small groups:

  • 🎮 Minecraft vanilla (up to 15 players) — USA VPS 500SSD (2 vCPU / 4 GB RAM) at $20/month
  • 🎮 CS2 competitive (10v10) — USA VPS 500SSD (2 vCPU / 4 GB RAM) at $20/month
  • 🎮 Valheim (up to 10 players) — USA VPS 500SSD (2 vCPU / 4 GB RAM) at $20/month
  • 🎮 Modded Minecraft or multiple game servers — USA VPS 30IPs or higher (4 vCPU / 8 GB RAM) at $50/month

All plans include KVM virtualization (required for game server kernel modules), 1 Gbps network ports, and SSD storage for fast world loading.

Final Thoughts

Hosting your own game server on a VPS is one of the most rewarding things you can do as a gamer or community admin. You get complete control, zero reliance on third-party services, and the satisfaction of running your own infrastructure. Whether it’s a private Minecraft world for friends, a competitive CS2 server for your team, or a Valheim adventure for your clan — the setup is well within reach on an afternoon.

Start with one game, get comfortable with the Linux setup, and expand from there. Questions along the way? VPS.DO’s support team is available 24/7. Open a ticket →

 

Fast • Reliable • Affordable VPS - DO It Now!

Get top VPS hosting with VPS.DO’s fast, low-cost plans. Try risk-free with our 7-day no-questions-asked refund and start today!