Running a Factorio Server on DigitalOcean
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.
One of the most fun aspects of Factorio is that it now has a multiplayer mode. Friends = fun! However, sometimes peer-to-peer connections can be perilous or impossible - if you’re not on the same network - and it can be nice to have a persistent server to allow your friends to play online while you’re offline and vice versa.
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.
Ubuntu 14.04as your Droplet image.
- Select the
$5 / monthtier 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
hostnamebox, and click create.
- Give DigitalOcean a few minutes to setup and configure your Droplet.
- Once configured, go into your Droplet and copy/record your
- Now you’ll need to SSH into your droplet:
- 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.gzto your local machine.
- Now you’ll use SFTP to upload the server files to your Droplet.
- Mac: Open a new Terminal. Run
- 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
after filling in the correct file path and name for the server
tar.gzthat you downloaded in step 1. (This will be a local path on your computer, something like
if you’re on a Mac)
- Mac: Open a new Terminal. Run
- Go back to your SSH shell. If you run
lsyou’ll see that the server
tar.gzis in you’re root directory!
tar -zxvf factorio_headless_x64_.X.X.X.tar.gzto unzip the server files.
cd factorioto enter your server folder.
./bin/x64/factorio --create MAPto create a map named
nano start.shand 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
Yto save and exit
chmod +x start.shto make
Running your server
./start.shto start your server. (Remember: When you first connect to your Droplet, you’ll need to do
cd factorioto 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
SFTP), 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. ↩