Skip to content

Instantly share code, notes, and snippets.

@cbednarski cbednarski/factorio.md
Last active Sep 16, 2019

Embed
What would you like to do?
Host a factorio server

Factorio Server

This guide assumes you are using Ubuntu and have some basic linux command-line know-how.

Download

Download the server https://www.factorio.com/download-headless/stable:

Install

adduser --disabled-login --no-create-home --gecos factorio factorio
mkdir /var/lib/factorio
mkdir /etc/factorio
mkdir /opt/factorio

Extract the archive to /opt/factorio

Factorio User

For security, don't run factorio as root. You'll need to create a user and chmod some things so the factorio user can access them.

adduser --disabled-login --no-create-home --gecos factorio factorio
chown -R factorio:factorio /var/lib/factorio/
chown -R root:root /opt/factorio
chmod -R a+x /opt/factorio/bin/x64/factorio
chmod a+r /etc/factorio/

Startup

Move your save file to /var/lib/factorio/saves and reference by name. You can start the server like this:

/opt/factorio/bin/x64/factorio -c /opt/factorio/config-path.cfg  --start-server zivix2.zip --latency-ms 100 --disallow-commands

Upstart

Make sure the uid/gid corresponds to the factorio user. You can see the correct one to use via:

cat /etc/passwd | grep factorio

Upstart file for /etc/init/factorio.conf

start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]

setuid 1001
setgid 1001

env DAEMON=/opt/factorio/bin/x64/factorio
env OPTS="-c /opt/factorio/config-path.cfg --start-server zivix2.zip --latency-ms 100 --disallow-commands"

respawn
respawn limit 5 5

exec $DAEMON $OPTS

After adding this run:

start factorio

Systemd

Systemd unit file for /usr/lib/systemd/system/factorio.service

[Unit]
Description=Factorio Server

[Service]
Type=simple
User=factorio
ExecStart=/opt/factorio/bin/x64/factorio -c /opt/factorio/config-path.cfg --start-server zivix3.zip --latency-ms 100 --disallow-commands --autosave-interval 10

After adding this run:

systemctl daemon-reload
systemctl start factorio
@darrylemoonman

This comment has been minimized.

Copy link

darrylemoonman commented Mar 28, 2016

when i run start factorio , i get start: Job failed to start , using Upstart. Any clues?

@imakiro

This comment has been minimized.

Copy link

imakiro commented Apr 30, 2016

Systemd : there is no folder /usr/lib/systemd/system on ubuntu 16.04. so no unit file can be created. Folder should be /etc/systemd/system

@NOBODY1213

This comment has been minimized.

Copy link

NOBODY1213 commented Dec 26, 2016

using raspbian, but the process is usually the same... works with other ubuntu projects, but anyway I did what the tutorial said but got stuck at Startup... console output is this:

pi@raspberrypi:~ $ /opt/factorio/bin/x64/factorio -c /opt/factorio/config-path.cfg --start-server zivix2.zip --latency-ms 100 --disallow-commands
-bash: /opt/factorio/bin/x64/factorio: cannot execute binary file: Exec format error

@NOBODY1213

This comment has been minimized.

Copy link

NOBODY1213 commented Dec 26, 2016

now I'm using ubuntu I get:
0.000 Error Util.cpp:57: There is no package core in /usr/share/factorio

@DIYglenn

This comment has been minimized.

Copy link

DIYglenn commented Jan 4, 2017

@NOBODY1213:
I'm pretty sure it won't run on your raspberry due to being compiled for X86-systems, not ARM.

Regarding the other error - Did you install factory to /usr/share/factorio? Otherwise, maybe it is under /opt/factorio?

@stormsh

This comment has been minimized.

Copy link

stormsh commented May 22, 2018

Hi there, thanks for the instructions, I got the Server running. I added a second server and want someone elso to look after them. I created an account with limited rights to serve that pupose. But I can't get into the /opt solder because obviously this user does not have the rights to do so. Is there a way to install the server somewhere else than the opt folder? And if not, why?
Thx 4 F1.

@pcnate

This comment has been minimized.

Copy link

pcnate commented May 26, 2018

you need to be root in order to put and modify files in /opt and /etc. You most likely can use sudo for this as long as you have been given access or own the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.