Setup Factorio Server
๐ ๏ธ Factorio Headless Server Setup on Linux (Systemd)
๐ฆ 1. Create a User for the Server
sudo useradd -m -r -s /bin/bash factorio
This creates a non-login system user named factorio
.
๐ 2. Set Up Directory and Download Server
sudo mkdir -p /opt/factorio
sudo chown factorio:factorio /opt/factorio
cd /opt/factorio
Download the latest headless server from Factorioโs website:
wget https://www.factorio.com/get-download/latest/headless/linux64 -O factorio_headless.tar.xz
Or upload form you computer to server:
scp factorio.x.y.tar.xy <user>@<server ip or hostname>:.
Extract it:
tar -xvf factorio_headless.tar.xz
rm factorio_headless.tar.xz
This extracts into a directory like factorio
. You can rename it or keep it as is:
mv factorio/* . && rmdir factorio
๐งช 3. Run the Server Once to Generate Files
Switch to the factorio
user and run the server once to create default files:
sudo -u factorio /opt/factorio/bin/x64/factorio --create /opt/factorio/saves/base-game.zip
This creates a basic save file.
โ๏ธ 4. Configure the Server
Edit /opt/factorio/data/server-settings.json
to adjust name, description, visibility, etc.
You can also copy the example:
cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.json
Edit it with:
sudo -u factorio nano /opt/factorio/data/server-settings.json
๐ 5. Create the Start Script
Create a simple script to launch the server:
sudo nano /opt/factorio/start-base
Paste this in:
#!/bin/bash
cd /opt/factorio
exec ./bin/x64/factorio \
--start-server ./saves/base-game.zip \
--server-settings ./data/server-settings.json
Then make it executable:
sudo chmod +x /opt/factorio/start-base
๐ง 6. Create a systemd Service
Create the service file:
sudo nano /etc/systemd/system/factorio.service
Paste the following:
[Unit]
Description=Factorio Headless Server
After=network.target
[Service]
User=factorio
Group=factorio
WorkingDirectory=/opt/factorio
ExecStart=/opt/factorio/start-base
Restart=on-failure
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
๐ 7. Enable and Start the Service
Reload systemd and start the service:
sudo systemctl daemon-reload
sudo systemctl enable factorio
sudo systemctl start factorio
๐ 8. Check Logs and Status
To check the status:
sudo systemctl status factorio
To follow the server logs:
journalctl -u factorio -f -o cat
๐งผ 9. Optional Cleanup
Delete the downloaded archive (if you havenโt already):
rm /opt/factorio_headless.tar.xz