Dec 31, 2015

Installing a Minecraft server on AWS

This one is for all the kids (and geek dads & moms) out there. I'm surprised I didn't get to write this sooner :)

Running your own Minecraft server in AWS is pretty straightforward, so here goes!

1) Create an EC2 instance

I've picked a t2.small instance (2 GB RAM) running the Amazon Linux AMI and costing $0.028 per hour at the time of writing. Anything smaller feels... small for a complex Java app, but you're welcome to try. Details and pricing for EC2 instances may be found here.

Only the security group needs to be tweaked: on top of SSH access, you also need to open a port for the server (default port is 25565). If you want to play with friends (which is kind of the point), allow access from anywhere.

Your inbound rules should look like this:

Select a key pair and launch your instance.

2) Install the Minecraft server

Once you ssh'ed into your instance, it's time to select a Minecraft version. Let's retrieve the list (conveniently hosted in S3) :

$ wget

My customer (ok, my son) wants to run 1.8.9, so let's download and extract this version:

$ mkdir minecraft
$ cd minecraft
$ wget

3) Configure the Minecraft server

Start it once:

$ java -jar minecraft_server.1.8.9.jar

It will fail and complain about approving the user agreement (bleh). All you need to do is to edit the eula.txt file:


Feel free to edit the file to add your favorite settings.

 4) Start the Minecraft server

The best way to start a long-running server without losing access to the console is to use screen. Here is a simple tutorial.

$ sudo yum install screen -y
$ screen java -jar minecraft_server.1.8.9.jar

Your server is running, congratulations. You should be able to connect to it using the Minecraft client.

In the console, you will see players joining and leaving the game, as well as their UUID, e.g.:

[17:08:11] [User Authenticator #1/INFO]: UUID of player _____Dante_____ is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

This UUID is useful to declare players as operators in ops.json:

$ cat ops.json
    "uuid": "
    "name": "_____Dante_____",
    "level": 4


That's it. Don't forget to detach from your server before ending your SSH session, or it will be killed (hint: CTRL-A D). And don't forget to stop the instance when you're not playing, it will save you money :)

Have a nice game and happy New Year!

1 comment:

  1. Would use tmux instead of screen, or better still: install supervisord and setup a startup to put in /etc/supervisor/conf.d:

    command=java -jar minecraft_server.1.8.9.jar
    directory= /home/ec2-user