Minecraft in the Cloud

Minecraft is a block based world building game for all ages that can be run on a number of platforms. For this guide, we will be using Amazon Web Services (AWS) to run a cloud based Minecraft server running Ubuntu so my friends and family can join and help me build up our own world together. There are some costs involved which we’ll cover in the next section.

Getting Started

Before we set up everything, there are a few things we’ll want to have ahead of time

  1. Minecraft for PC / Mac — $30
  2. Minecraft server JAR — Free. We will be able to get this through the command line
  3. AWS Account — Free, but the EC2 instance will have a variable monthly cost based on usage

Note: in the bash script snippets below, # are used to denote comments. These are not commands to execute. Anything after a $ is a command that should be executed.

Create an AMI (Amazon EC2 Instance)

  1. Log into your AWS account and from the dashboard, select EC2
  2. Select Instance Type (Ubuntu 64-bit)
Step 2: Select AMI Instance Type

3. Select Instance Size (t2.small), which has 2G of RAM. This should be sufficient for about 20 people.

Step 3: Select Instance Size

4. Configure your instance. The below are the default values provided by AWS.

Step 4: Configure Instance (using defaults)

5. From here, you can go directly to the Configure Security Groups step. I have made two rules, described below

Step 5: Configure Security Groups for SSH and Custom TCP

a) SSH — This rule configures SSH connections only from your IP address. Use WhatIsMyIP to figure out what value to use as your custom IP value. Note, if your IP changes, you will need to update the source for this rule.

b) Custom TCP — This rule configures TCP connections (of which HTTP is a kind of, but specific to port 80) to allow all incoming requests to your server, however we set the port range to only 25565, since that is the port the Minecraft server will run on.

6. Now click Review and Launch and click Launch

7. Now you will be prompted to select / create and save a .pem file (private SSH key). I choose to create a new one with the name minecraft and saved mine in my ~/.ssh/ folder on my local machine. After you have downloaded it, you can now Launch the instance.

Step 7: Create a Keypair (.pem)

8. Go to your EC2 Dashboard, and you should see your instance launching. Of particular note you will want to note the Public IP. This is outward facing IP Address for your AMI that we will use when connecting to the Minecraft server.

Step 8: Instance Launching

9. Before we setup the server, let’s make sure we can SSH into our instance. Open a terminal and chmod the .pem file you saved, then SSH into your instance using the public IP address using user ubuntu

# chmod the pem file you saved 
$ chmod 600 ~/.ssh/minecraft.pem

# ssh into your instance
$ ssh -i ~/.ssh/minecraft.pem ubuntu@

# if successful, you should see this
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-48-generic x86_64)

* Documentation: https://help.ubuntu.com/

System information as of Mon Nov 16 02:09:20 UTC 2015

System load: 0.08 Memory usage: 2% Processes: 82
Usage of /: 9.8% of 7.74GB Swap usage: 0% Users logged in: 0

Graph this data and manage this system at:

Get cloud support with Ubuntu Advantage Cloud Guest:

0 packages can be updated.
0 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.


Set up the Server

  1. Since Java is not installed by default, let’s Install it
$ sudo apt-add-repository ppa:webupd8team/java
# press ENTER to continue

$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer
# enter Y and press enter to continue
# press enter to OK and agree to the Oracle license
# select Yes and press enter to accept the terms of the license

# if successful, you should see output from this command
$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

2. Lets create a directory and change into to prepare for installing and running the Minecraft server

$ mkdir ~/minecraft
$ cd ~/minecraft

3. Now let’s download the Minecraft server JAR

$ wget https://s3.amazonaws.com/Minecraft.Download/versions/1.8.1/minecraft_server.1.8.1.jar

4. Let’s start the server

# -Xms is the minimum RAM to allocate, -Xmx is the maximum amount of RAM to allocate
$ java -Xms512M -Xmx1000M -jar minecraft_server.1.8.1.jar -o true

5. The server doesn’t start, and we are prompted to accept the Minecraft EULA (End User License Agreement). To do this, we will use a command line text editor called vim

# open the file
$ vim eula.txt

# press i to enter insert mode
# arrow down and over to the last line, eula=false
# delete false, and type true
# hit escape
# hit shift+:
# hit wq
# hit enter

6. Now, lets try that again…

$ java -Xms512M -Xmx1000M -jar minecraft_server.1.8.1.jar -o true

# note, there will be a one-time startup error for a missing file.
Failed to load user banlist:
java.io.FileNotFoundException: banned-players.json (No such file or directory)

# This OK and expected, in fact the file will be made for us and so we won't see this error next time we start the server

7. If all was successful, we should see this in our terminal

[02:55:49] [Server thread/INFO]: Preparing level "world"
[02:55:49] [Server thread/INFO]: Preparing start region for level 0
[02:55:50] [Server thread/INFO]: Preparing spawn area: 4%
[02:55:51] [Server thread/INFO]: Preparing spawn area: 8%
[02:55:52] [Server thread/INFO]: Preparing spawn area: 14%
[02:55:53] [Server thread/INFO]: Preparing spawn area: 20%
[02:55:54] [Server thread/INFO]: Preparing spawn area: 22%
[02:55:55] [Server thread/INFO]: Preparing spawn area: 25%
[02:55:56] [Server thread/INFO]: Preparing spawn area: 32%
[02:55:57] [Server thread/INFO]: Preparing spawn area: 41%
[02:55:58] [Server thread/INFO]: Preparing spawn area: 54%
[02:55:59] [Server thread/INFO]: Preparing spawn area: 60%
[02:56:00] [Server thread/INFO]: Preparing spawn area: 74%
[02:56:01] [Server thread/INFO]: Preparing spawn area: 91%
[02:56:02] [Server thread/INFO]: Done (13.399s)! For help, type "help" or "?"

8. Now, lets fire up Minecraft and connect to our new server, using multiplayer mode, clicking add server. and entering our our public IP

Connect to theMinecraft Server

9. ???

10. Profit!

Game play!

Server Management

Create a Startup Script

Instead of having to remember the entire command to start the server each time, a quick shortcut is to save it as a bash script that you can execute instead

# note, if the server is already running, stop it first

# keep this script where the Minecraft server JAR is located, which per this guide, is in
$ cd ~/minecraft

# use vim to create a new file that we'll call server.sh
$ vim server.sh

# press i to enter insert mode
# copy paste the startup command: java -Xms512M -Xmx1000M -jar minecraft_server.1.8.1.jar -o true
# hit escape
# hit shift+:
# hit wq
# hit enter

# now we can simply start our server using
$ sh server.sh

Create a User Whitelist

Unless you want to create a completely open server, you will likely want to limit access to just friends. To do so, open whitelist.json and add usernames and their ID's in JSON format, as an array. You can use this website to get UUIDs

$ vim whitelist.json

"uuid": "sampleUUID1",
"name": "sampleUsername1"
"uuid": "sampleUUID2",
"name": "sampleUsername2"

Persisting the Server

Naturally, the server needs to stay up and running in order for players to connect at anytime. However, you might notice that if you exit from your SSH session or close your terminal tab, the server will stop and any players will get disconnected from the server. To avoid this, you can use screen to persist a shell session.

  1. Create an named screen session
$ screen -S mcserver

2. Now start the server like we did earlier. Or use CreateaStartupScript (recommended)

$ java -Xms512M -Xmx1000M -jar minecraft_server.1.8.1.jar -o true

3. You can now connect to the Minecraft server and close out your SSH session without getting disconnected (just don’t use Ctrl+C in a screen with the server running)

Killing Screen Sessions

Used for killing a persisted server session

$ screen -ls
There is a screen on:
3397.mcserver (11/15/2015 11:13:00 PM) (Detached)
1 Socket in /var/run/screen/S-ubuntu.
ubuntu@ip-172-30-2-232:~$ screen -X -S 6422 quit

Monitoring the Server Logs

If you ever want to monitor the activity happening on the server, you can watch the server logs in real-time

$ tail -f ~/minecraft/logs/

Stop / Restart the Server

If you ever need to stop and / or restart the server, use the following

# find the PID (process ID) of the server
$ ps aux | grep java
ubuntu 2920 3.3 17.6 1776204 361764 pts/2 Sl+ 03:20 0:34 java -Xms512M -Xmx1000M -jar minecraft_server.1.8.1.jar -o true
ubuntu 3089 0.0 0.0 10460 932 pts/0 S+ 03:38 0:00 grep --color=auto java

# kill the process running the minecraft_server.jar
$ kill -9 2920

# you can restart the server using the startup command from this guide

Game Modes

There are different modes for playing Minecraft. One of the more popular modes is creative mode. To enable this, or any other mode, use vim to edit server.properties file. Per this guide, edit

$ vim ~/minecraft/server.properties

# change this line to be