Hosting with AWS

You can host completely for free using AWS free credits

Hosting a Battlesnake on AWS EC2

This guide walks you through creating an AWS account, launching a small virtual server (t3.micro), opening the firewall so our game engine can reach your server over HTTP, and of course getting your snake code running.

Step 1: Creating an AWS Account

  1. Go to aws.amazon.com and click "Create an AWS Account"
  2. Enter your Root user email address and choose an AWS account name (e.g., battlesnake-dev).
  3. Verify your email address with the 6 digit code AWS sends you, choose a strong password.
  4. Select Personal/for your own projects for the account type and fill in your contact information.
  5. Enter a valid credit or debit card.
    • Note on Billing: New AWS accounts include Free Tier access and introductory credits, so a single t3.micro instance will cost $0 to run while within free tier limits. You just need to remember to stop or terminate your instance at the end of the event (or within the next few months.)
  6. Complete the phone/SMS identity verification, select the Basic support - Free plan, and click Complete sign up.
  7. Log in to the AWS Management Console using your Root user email and password.

Step 2: Launch a t3.micro Virtual Server (EC2)

If you're curious, EC2 stands for Elastic Computing cloud

us-west-2 is a good choice for proximity to our API.

  1. In the top search bar, type EC2 and click EC2 under Services.
  2. Click the orange Launch instance button.
  3. Name and tags: Give your server a name, such as my-battlesnake.
  4. Application and OS Images (AMI): Select Ubuntu (Ubuntu Server 24.04 LTS or 26.04 LTS). It is beginner friendly and has preinstalled tools for Python, Node.js, and Git.
  5. Instance type: Click the dropdown and select t3.micro (2 vCPUs, 2 GiB Memory). You can also choose a larger instance if you like.
  6. Key pair (login):
    • Select Proceed without a key pair (we will use AWS's built-in browser terminal to keep things simple, though you can create a .pem key pair if you prefer connecting via SSH from your own terminal).
  7. Network settings (Crucial for HTTP requests!):
    • Click Edit in the top-right of the Network settings box.
    • Keep the default VPC and Subnet, and ensure Auto-assign public IP is set to Enable.
    • Under Firewall (security groups), select Create security group.
    • Keep the default SSH rule, then click Add security group rule to let Battlesnake talk to your server:
      • Type: Custom TCP
      • Port range: 8000 (or whatever port your Battlesnake app listens. Default 8000 for Python or 3000/8080 for Nodejs)
      • Source type: Anywhere (0.0.0.0/0)
    • (Optional) Add another rule for Type: HTTP (Port 80, Source 0.0.0.0/0) in case you ever run your app directly on port 80.
  8. Leave Configure storage at the default (8 GiB gp3) and click the orange Launch instance button.

Step 3: Connect to Your Server

  1. Click Instances in the left sidebar (or click the instance ID link on the confirmation banner).
  2. Wait until the Instance state says Running (this takes about 30 seconds).
  3. Check the box next to my-battlesnake. Look at the details panel at the bottom and copy your Public IPv4 address (e.g., 54.123.45.67). You will need this in Step 5.
  4. Click the Connect button near the top right.
  5. Make sure you are on the EC2 Instance Connect tab, leave the username as ubuntu, and click Connect.

A new browser tab will open with a black Linux command-line terminal inside your AWS server.

Step 4: Get Your Battlesnake Code onto the Server

First, update the server's package list by typing this command and pressing Enter:

sudo apt update

Then install the Python tools you need (or Node.js or other language-specific tools):

sudo apt install -y git python3-pip python3-venv

Clone your GitHub repository:

git clone https://github.com/BattlesnakeOfficial/starter-snake-python.git
cd starter-snake-python

Set up and run your snake (this may differ depending on your code):

python3 -m venv venv

source venv/bin/activate

pip install -r requirements.txt

Run it (this may be different for your own code):

# Example for the official Python starter snake (runs on port 8000 by default)
python3 main.py

However, this will stop running when you close the terminal. You can either run it like this:

nohup python3 main.py > snake.log 2>&1 &

Or research how to use a WSGI tool to properly run and serve the code.

In either case, your snake should now be accessible by navigating to:

http://<your-ip-address>:8000/

For example:

http://54.123.45.67:8000/

Paste the address into a browser, and you should see a JSON response.