keepcalculator

06 Numbers and Powers

Host a Game Server on AWS Cheaply: Step-by-Step

Card No. 06·73842 · Updated · Standard formula, shown below

This guide shows you how to run a dedicated game server on Amazon Web Services (AWS) for a fraction of the cost of a managed host. You’ll set up an EC2 instance, install the server software, and configure it for remote play—while using cost-saving tactics like spot instances and scheduled shutdowns. No prior AWS experience is needed, but you’ll need an AWS account and basic comfort with a command line.

What You’ll Need

  • An AWS account (sign up at aws.amazon.com). You’ll need a credit card; the free tier may cover some costs initially, but a game server typically exceeds free tier limits.
  • A game that has a dedicated server option (e.g., Minecraft Java Edition, Valheim, ARK, Terraria, Counter-Strike).
  • SSH client: On Windows, use PuTTY or the built-in OpenSSH; on macOS/Linux, use the terminal.
  • Basic familiarity with editing text files and running commands in a terminal.
  • Optional: A static IP or a dynamic DNS service if you want a fixed address for your server.

Step-by-Step

  1. Choose a region and instance type. Log in to AWS Console, go to EC2, and select a region close to your players. For most game servers (Minecraft, Valheim, ARK), a general-purpose instance like t3.medium or t3.large is sufficient. For CPU-heavy games (e.g., Factorio), consider c5.large. Avoid GPU instances unless your game uses them (rare).
  2. Create a key pair. In the EC2 dashboard, under “Network & Security”, click “Key Pairs”. Create a new key pair, download the .pem file, and store it securely. This is your only way to SSH into the instance.
  3. Launch a Spot Instance (the big cost saver). Go to “Instances” → “Launch Instances”. Under “Instance type”, select your chosen type. For “Purchase option”, choose “Spot instance”. Spot instances are up to 70% cheaper than on-demand, but they can be terminated by AWS with a 2-minute warning. If you need a persistent server, you can use on-demand, but for a small group, spot is ideal. Set the “Spot request” to “persistent” to auto-restart when capacity is available.
  4. Configure storage and security group. In “Configure storage”, set the size to at least 20 GB (games and worlds can be large). Use SSD (gp3) for speed. In “Configure security group”, create a new one and add rules: allow SSH (port 22) from your IP only, and allow the game port (e.g., 25565 for Minecraft, 2456 for Valheim) from 0.0.0.0/0 (or your friends’ IPs if you want extra security).
  5. Launch and connect. Click “Launch”. Wait for the instance to enter “running” state. Select it, click “Connect”, and follow the SSH instructions. For Windows, use PuTTY with the .pem converted to .ppk; for Linux/macOS, use the ssh command with the .pem file.
  6. Install the game server. Once connected, update the system: sudo apt update && sudo apt upgrade -y (for Ubuntu). Install dependencies like Java (for Minecraft) or SteamCMD (for many games). Download the server files from the game’s official source. For example, for Minecraft: wget https://launcher.mojang.com/v1/objects/.../server.jar. Accept the EULA by editing eula.txt and setting eula=true.
  7. Configure the server. Edit the server.properties (or equivalent) to set your desired game settings: max players, world name, difficulty, etc. For Valheim, you’ll need to install SteamCMD and run the dedicated server script. For ARK, use the ARK server manager.
  8. Start the server. Run the server in a way that keeps it running after you log out. Use screen or tmux: sudo apt install screen, then screen -S game, then run your start command. Detach with Ctrl+A, D. To reattach later, use screen -r game.
  9. Set up automatic shutdown (another cost saver). Install a cron job to stop the instance when idle. For example, create a script that checks if the server process is running; if not, run sudo shutdown -h now. Or use AWS Instance Scheduler (a free tool) to shut down during off-hours.
  10. Test and share. From your gaming PC, connect to the server using the public IP of your instance (found in EC2 console). If you want a friendly name, set up an Elastic IP (static IP) or use a dynamic DNS service. Note that Elastic IPs cost money if not attached to a running instance, so only use one if needed.

Common Mistakes

  • Forgetting to open the game port in the security group. You’ll get “connection refused” errors. Double-check that the port rule matches the game’s default port.
  • Using an on-demand instance when spot would do. Spot instances can save 60-70%. If you’re okay with occasional restarts, use spot.
  • Leaving the instance running 24/7. This is the #1 cost killer. Even a t3.medium on-demand costs about $30/month; spot is ~$10, but leaving it on all month adds up. Use auto-shutdown.
  • Choosing too large an instance. A t3.large is overkill for 5 players on Minecraft. Start small and scale up only if needed.
  • Not backing up your world. If the spot instance is terminated, you lose everything. Use AWS Backup or simply copy the world folder to S3 regularly.

Tips

  • Use Spot Instances with a persistent request. This way, if AWS reclaims the capacity, the instance will automatically restart later (though you may lose unsaved data).
  • Set a budget alert. In AWS Billing, create a budget of $10/month and an alert to email you when you approach it. This prevents surprise bills.
  • Use a lightweight OS. Ubuntu Server LTS is fine, but consider Amazon Linux 2 if you want tighter AWS integration.
  • Automate startup with a script. Use a user-data script during launch to auto-install the server, so if the instance restarts, the server comes back automatically.
  • Use a custom AMI. After configuring your server, create an AMI (image) of the instance. Then you can launch new instances from that image in minutes.
  • Consider using AWS Lightsail for simplicity. Lightsail has a flat monthly price (e.g., $10/month) and is easier to manage, but you lose some of the spot instance savings.

Troubleshooting

  • Can’t connect to the server. Check the security group rules—ensure the game port is open. Also check the instance’s public IP hasn’t changed (if you didn’t use an Elastic IP). Test with telnet your-ip port from your local machine.
  • Server crashes on startup. Look at the server logs (usually in the server directory). Common issues: missing Java version, not accepting EULA, or insufficient RAM. Increase memory with java -Xmx2G -jar server.jar.
  • High latency for players. Move the instance to a region closer to players. Also check if your ISP is throttling game traffic. Use ping and traceroute to diagnose.
  • Spot instance terminated. If you have a persistent request, it will relaunch automatically, but you’ll lose any data not saved. That’s why backups are crucial.
  • SSH key permission error (Linux/macOS). Run chmod 400 yourkey.pem to fix “permissions too open” errors.
  • Server runs but world doesn’t save. Ensure the server has write permissions to the world folder. Run chown -R ubuntu:ubuntu /path/to/server.

Frequently Asked Questions

Is it cheaper than renting a game server host?

Yes, if you use a spot instance and shut it down when idle. A small Minecraft server for 5-10 players can cost as little as $5-10/month on AWS, while managed hosts often charge $15-30/month. However, you trade ease of use for cost.

Can I use the AWS free tier?

The free tier includes a t2.micro instance for 750 hours/month for 12 months, but t2.micro is too weak for most game servers (1GB RAM). You can try it for a very small game like Terraria, but expect to upgrade.

What if my game isn’t in the default ports list?

You can open any port. Just add a custom TCP rule in the security group. The game’s documentation will tell you which port(s) to use.

How do I back up my world?

Stop the server, then copy the world folder to an S3 bucket using the AWS CLI: aws s3 cp world s3://your-bucket/world --recursive. Schedule this with cron.

Can I run multiple game servers on one instance?

Yes, if the instance has enough RAM and CPU. Use separate directories and different ports. Monitor resource usage with htop.

What happens if I exceed my budget?

AWS will not stop your instance automatically unless you set up billing alerts and a script to shut down. Always set a budget alert to avoid surprise charges.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →