Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to setup a Factorio Headless Server

[LINUX] Factorio Headless Server Guide

So, with credit to the Factorio wiki and cbednarski's helpful gist, I managed to eventually setup a Factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records.

The specific distro/version I'm using for this guide being Ubuntu Server 16.04.1 LTS. Although, that shouldn't matter, as long as your distro supports systemd (just for this guide, not a Factorio headless requirement, although most distros use it as standard now). The version of Factorio I shall be using is 0.14.20, although should work for any version of Factorio 0.14.12 and higher.

Just a note to newcomers: If there are any issues with the installation steps, people in the comments are doing a good job at mentioning steps required by newer installations. I don't really play anymore and haven't setup or managed a Factorio server in years, so I'll advise if something isn't working to check the comments and forks. Much love <3


If you prefer a simple, automated setup, Bisa has a really handy init script that will do most of the work for you!


I'm very much into Docker these days, in which there is a brilliant container setup and ready for this if you wish to use that instead.


  • *nix distro, setup and ready to go
  • The UDP port used for Factorio, default 34197, forwarded through your router. I won't go into how to do this here as it's a seperate tutorial in of itself, but you can easily Google "{routers model/manufacturer} port forward" and find the desired results.
  • Optional - Setup SSH for remote access, this may be handy if you wish to upload/download saves via scp (?). If you would like to do this, it's recommended that you disable password login and use SSH keys.
  • Tip - If you ever miss sudo from the beginning of a command, sudo !! will repeat it, but elevated.
  • That's it!

Step 0 :: Patches & Security!

With it being a fresh installation, as with any OS, make sure to update your system. Run sudo apt update && sudo apt full-upgrade. This will first check the relevant repo's for package updates, then run the update process.

If your server is running from behind your edge router/firewall, then enabling the firewall isn't a necessary step. So skip to the next step if you don't want to enable it.

I like to enable the firewall before getting started on setup, just personal preference. This is as simple as sudo ufw enable. UFW being Uncomplicated Firewall, in which it really is!

Let's allow Factorio through on its default port (or a port of your chosing), sudo ufw allow 34197/udp. You may also want to allow SSH connections through at this point, if you are using it.

As this is an internet facing server, you may want to install and configure something like fail2ban to help with repeated non-authorised login attempts, but that is up to you.

Step 1 :: Download

I'm going to be working out of my home directory, just for simplicity. Let's grab the headless server from Factorio's download site via wget onto the server.

wget -O factorio_headless.tar.gz

Unfortunately, the url for the download isn't static, so you'll have to change the version in the url to what version you require (stable or experimental). Easiest way to find out the url is to go to the Factorio server download page and find the url from the link provided under the version number.

Also, as they redirect download requests, wget will not name the file correctly. The easiest way to rectify it is to manually set the file name using the -O flag and manually providing the file name as used in the example above.

Wait for the file to download before proceeding.

Step 2 :: Directories

Factorio runs out of the /opt directory, a directory resevered in UNIX for non-default software installation.

So before extracting the headless archive, lets change our working directory, cd /opt.

Now its time to extract the headless archive, sudo tar -xzf ~/factorio_headless.tar.gz. The -xzf flags are basically; extract a gzipped archive file. This will extract the downloaded archive to your current directory, and should have created a Factorio folder. You can check that /opt/factorio exists by running ls (?), and seeing if the factorio directory is listed, as we are working out of /opt already.

Just for the sake of keeping things tidy, I'd also delete the downloaded archive rm ~/factorio_headless.tar.gz, as we are now finished with it.

If you wish to add any mods or saves, you can do so by first creating the mods and saves directories within /opt/factorio. sudo mkdir /opt/factorio/saves and sudo mkdir /opt/factorio/mods should achieve this, then you may copy the save & mod archives into the relevant folders.

Step 3 :: Environment

As you don't want Factorio running as root, let's setup a user that it can run under. The user won't need a lot of functionality, as it's only going to be running Factorio and won't need to be logged into, so let's provide some flags to create a really basic user:

sudo adduser --disabled-login --no-create-home --gecos factorio factorio

The above command will add a user, not setting a password --disabled-login, without creating a home directory in /home --no-create-home, without asking for user information --gecos, create user factorio and add them/create the group factorio.

Now that the new user is created, we need to make it the owner of the Factorio directory so that it can access and perform operations within it, sudo chown -R factorio:factorio /opt/factorio. The -R flag being recursive.

Step 4 :: Factorio Configuration

Factorio headless, as of 0.14.12, requires a JSON formatted config file. They provide an example one to get you started, in which can be copied and then edited to suit your requirements.

First, lets change directory cd /opt/factorio/data where the server-settings.example.json config file is located, it's not necessary, but just the way I do things. Now to make a copy of the config file under its working name sudo cp server-settings.example.json server-settings.json and then edit it with a text editor of your choice, I like nano as its easy sudo nano server-settings.json.

The configuration is fairly straight forward and mirrors that of the GUI when setting up a server via the standard edition of Factorio. Here is the configuration reference. Configure it as you wish, save, exit and proceed onto the next step.

Step 5 :: systemd

So, we want Factorio to run as a service. So lets create a new service for Factorio within the systemd service scheduler. Again, I like nano as its easy, but any text editor will do sudo nano /etc/systemd/system/factorio.service. The service should contain the following:

Description=Factorio Headless Server

ExecStart=/opt/factorio/bin/x64/factorio --start-server /opt/factorio/saves/{save_file}.zip --server-settings /opt/factorio/data/server-settings.json

Change the {save_file} for the file name of your save. You may also want to swap out --start-server /opt/factorio/saves/{save_file}.zip for --start-server-load-latest, which will automatically pull through the latest version of your world across manual and auto saves. If you wish to look at more parameters, there is more information on the Factorio multiplayer wiki.

Save the file and exit. Time to start the service and see if our setup has worked!

Firstly, reload the available service daemons systemctl daemon-reload, now start the newly created service systemctl start factorio and see if it's running systemctl status factorio.service. That is the output from the Factorio server, any errors or configuration issues will present themselves here if you ever need to debug.

If you do make any configuration changes, you'll need to restart the service sudo systemctl restart factorio.service.

Step Finished :: Play!

That's it! You should now have a working Factorio server. Head over to your client and under "Multiplayer" > "Connect to a server", provide your address that you set it up against (and port if you changed it from the default) and play spend hours labouring over tiny details to maximize efficiency!


  • How to upgrade
  • How to create/scp your own save (re-apply chown)

With a quick shout out to for making MD editing a more pleasant experience...

Copy link

Helveg commented May 24, 2017

Hi! I can run factorio with sudo, but when I, without sudo, or the service tries to execute factorio it throws an error:
"Error Util.cpp:57: Could not move file "factorio-current.log". Another instance of Factorio is probably already running."

Any ideas on how to fix this?

EDIT: It works once I use chown -hR instead of chown -R.

Copy link

tim-phillips commented Jul 20, 2017

Love you

Copy link

aisthetikos commented Jul 20, 2017

Hello! Thanks for the guide. I am attempting to install and I have had a few hiccups. The first was that I was getting the error "/info.json not found" I found the file in the /opt/factorio/data/base folder and moved it to /opt/factorio. So far so good. I am no getting the erro "failed to load basic prototypes, base mod or a base mod replacement is not enabled." And "equipment grid prototype required but missing."

I do not currently have any mods installed, and no mod folder was created.

Any help is appreciated! Thank you.

Copy link

PurpleRaptr commented Aug 1, 2017

Im having trouble extracting the file. says not in gzip format

can anyone help me out here?

Copy link

Lewis98 commented Aug 3, 2017

@PurpleRaptr try using 'sudo tar -xf ~/factorio_headless.tar.gz' instead

Copy link

philihp commented Aug 4, 2017

We've been tinkering around with using Chef to provision game servers. This automates setting up users, creating directories, making Factorio run as a service, etc.

Copy link

steezeburger commented Aug 5, 2017

I'm having the same issues as you @aisthetikos, although copying the info.json file did not help. I'm still getting the first error. Did you make any progress?

Copy link

procheeseburger commented Oct 18, 2017

possible you can do the "how to update" part? The only thing I can find online is to use scripts. Shouldn't I be able to just replace the game file?!

Copy link

sonerb commented Nov 15, 2017

When i try to start server. I got a killed message.


Can anyone help me?

Copy link

othyn commented Nov 18, 2017

Oh man, I never got notified of the comments... below are some updated guides that I found as I am far out of the loop now, haven't touched Factorio in months.

Copy link

maggotkrus commented Nov 25, 2017

i think need add

systemctl enable factorio

for autostarting server

Copy link

MOB-atheist commented Dec 21, 2017

Hi, thanks, I just had a problem with the installation package, the newest package comes with xz extension and no gz, replacing -xzf with -xf solve the problem, because tar recognizes the format by itself

Copy link

jakevossen5 commented Feb 21, 2018

For some reason I was having an error 203 when this started (ubuntu 16.04).

I fixed this by running chmod +x /opt/factorio/bin/x64/factorio

Copy link

TalionOak commented Mar 15, 2018

Copy link

chrisjmendoza commented Apr 11, 2018


Copy link

davidjeddy commented Jun 9, 2018

Much appreciated, thank you.

AWS T2 nano running Ubuntu 16.04 Server.

Copy link

Claesson3835 commented Jun 19, 2018

Great Guide, Thank you very much!
I signed up for a free AWS T2 Micro, and just installed this. I will try tonight!
@davidjeddy - Do you have any performance issues with AWS T2 Nano?

Copy link

Runaround008 commented Sep 7, 2018

im running ubunut server 16.04.5 with headless 0.16.51. I followed the instructions until i get to the "sudo systemctl start factorio" command and get the error:
"Failed to start factorio.service: Unit factorio.service not found."
i cant get it to work.
please help

Copy link

ghost commented Sep 20, 2018

Hi !
There's an url now for the latest stable headless version
It give's you an *tar.xz file

Copy link

obliwetator commented Feb 26, 2019

The guide works flawlessly. Only problem is i cannot find my server IP address. I can connect from the server browser but i wish to learn how to check the server IP. I am hosting the server on GCP if that helps

Copy link

nilcolor commented Mar 11, 2019

@PatrykStyla run curl from the server's console.
This will print your IP address like so:

λ curl

Copy link

sn1ce commented Jul 9, 2019

Nice work mate! Works like a charm.

@PatrykStyla just go in your factorio Server console and type in "ip a | grep global"

Copy link

seewip commented Sep 6, 2019

To autostart Factorio the systemd needs to be slightly edited (source):

Description=Factorio Server

ExecStart=/opt/factorio/bin/x64/factorio --start-server /opt/factorio/saves/{save_file}.zip --server-settings /opt/factorio/data/server-settings.json


Then after systemctl daemon-reload you can use systemctl enable factorio.service and the dedicated server should start on boot.

Copy link

Igneous01 commented Jan 29, 2021

Thanks for sharing this! I've forked a version and added instructions on how to setup a dedicated server on AWS using EC2 and Linux AMI image.

Feel free to include this into your repo as well so it helps others!

Copy link

NeitoFR commented Mar 25, 2021

This tutorial is made with so much love and empathy, real king here. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment