If you haven’t yet played Factorio, I think you should. Especially if you have any interest in logistics problems, circuit design, or coding. Sure, you don’t do any coding or circuit design in Factorio, but the main gameplay loop will have you tackling similar problems.
Enter DigitalOcean1. For ~$5 a month, you can have your own self-hosted Factorio server that can handle around ~5 concurrent players without and problems.
Let’s get started.
Setting up your Droplet
- Make an account on DigitalOcean and add your payment details to be able to create droplets2.
- Go to your “Droplets” page and click
Create a New Droplet
. - Select
Ubuntu 14.04
as your Droplet image. - Select the
$5 / month
tier for your Droplet size. - Select the closest datacenter region to where the majority of your players will be located.
- Enter a sensible name in the
hostname
box, and click create. - Give DigitalOcean a few minutes to setup and configure your Droplet.
- Once configured, go into your Droplet and copy/record your
IPv4
address. - Now you’ll need to SSH into your droplet:
-
Mac (& Linux): Open Terminal (it’s in your Utilities folder) and run
ssh root@YOUR_IP_ADDRESS
-
Windows: Download and install PuTTY and follow this guide for setting up an SSH session at
root@YOUR_IP_ADDRESS
-
- Check your email for the root
password
. DigitalOcean sends you an email with the default root password. - Create a sensibly secure password when you are prompted to do so.
Setting up your Server
-
Go to the Factorio Download Page for the headless server package and download the
.tar.gz
to your local machine. -
Now you’ll use SFTP to upload the server files to your Droplet.
- Mac: Open a new Terminal. Run
sftp root@YOUR_IP_ADDRESS
. - Windows: Follow this guide to get a PSFTP shell running at
root@YOUR_IP_ADDRESS
. Login with your password.
After getting into your Droplet with SFTP, run
put /path/to/your/server/download/factorio_headless_x64_.X.X.X.tar.gz
after filling in the correct file path and name for the server
tar.gz
that you downloaded in step 1. (This will be a local path on your computer, something like/Users/<YOUR_USERNAME>/Downloads/factorio_headless_x64_X.X.X.tar.gz
if you’re on a Mac)
- Mac: Open a new Terminal. Run
-
Go back to your SSH shell. If you run
ls
you’ll see that the servertar.gz
is in you’re root directory! -
Run
tar -zxvf factorio_headless_x64_.X.X.X.tar.gz
to unzip the server files. -
Run
cd factorio
to enter your server folder. -
Run
./bin/x64/factorio --create MAP
to create a map namedMAP
3. -
Run
nano start.sh
and copy in the following code:#!/bin/sh ./bin/x64/factorio --latency-ms 150 --autosave-interval 2 --autosave-slots 10 --disallow-commands --start-server MAP
(Of course, these settings can be customized to your liking. You can see all the available settings by running
./bin/x64/factorio --help
) -
Type
Ctrl-X
thenY
to save and exitnano
. -
Run
chmod +x start.sh
to makestart.sh
executable.
Running your server
- Run
./start.sh
to start your server. (Remember: When you first connect to your Droplet, you’ll need to docd factorio
to get into your server folder) - Launch Factorio on your PC. Click
Play -> Multiplayer -> Connect to Game
. - Paste in your newly minted IP (the same one as you used for
SSH
andSFTP
), and you’re good to go!
Good luck, and have fun. Factorio is a super addicting, afternoon-consuming type of game, so get ready to spend a lot of time in this new server.
-
Though I write about how to do this with DigitalOcean, you could easily run these same settings on AWS, or perhaps even a RaspberryPi with similar results. ↩︎
-
‘Droplets’ are DigitalOcean’s naming convention for server instances. ↩︎
-
You can customize your map name, or upload a custom map to the
/factorio/saves/
folder if you wish. ↩︎