Article

Table of Contents
Theme:
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles.

How to Install a Factorio Server on Debian 11

Last Updated: Thu, Jul 14, 2022
Debian Game Servers

Factorio is a simulation game developed by Wube Software that lets you build and maintain factories. This guide shows you how to download, install, and configure a Factorio server on a Debian 11 cloud server, using the official Linux server package provided by Wube Software.

Prerequisites

To use the Factorio server, you also need your own copy of the game.

1. Download the Factorio Server

  1. Log in as the non-root user.
  2. Make sure you are in your user's home directory.

    $ cd
    
  3. Download the latest version of the Factorio server package.

    $ wget -O factorio.tar.xz https://www.factorio.com/get-download/latest/headless/linux64
    
  4. The file downloaded is in a compressed format. Decompress it using tar.

    $ tar xJvf factorio.tar.xz
    
  5. Change to the newly extracted folder.

    $ cd factorio
    

2. Create a Save File

The Factorio server requires a save file. You can upload your own save file to the server if you already have one. Or, uses these steps to generate a new save file on the server.

  1. Create a new directory to store the save files.

    $ mkdir savegames
    
  2. Run the factorio binary using the --create flag to generate a new save file. If you have already uploaded your own save file, you can skip this step.

    $ bin/x64/factorio --create ./savegames/world.zip
    

This generates a new save file called world.zip in the savegames folder.

3. Create a Configuration File

Factorio includes a default server configuration file, which you can use as a template.

Make a copy of the default file.

$ cp data/server-settings.example.json server-settings.json

Edit the new configuration file.

$ nano server-settings.json

You should read the comments in the configuration file and make any changes you need for your server.

4. Firewall Configuration

Debian 11 has the ufw firewall enabled by default, which blocks connections from the internet. You need to create a new firewall rule to allow connections on the Factorio server's default port. If you changed the default port in the server-settings.json file, you need to change it in the ufw allow command too.

$ sudo ufw allow 34197/udp

Reload ufw to apply the new rule.

$ sudo ufw reload

Check the status of ufw. It should list your newly created firewall rule.

$ sudo ufw status

If you are using a Vultr Firewall on your VPS, you need to create a similar rule in the Vultr Firewall control panel.

5. Test the Server

You're now ready to start the server for the first time. After the server has started, you can test it by connecting to your VPS's IP address in the Factorio multiplayer menu. You can find the IP address on the Instances tab in the Vultr control panel.

$ bin/x64/factorio --start-server ./savegames/world.zip --server-settings ./server-settings.json

After you've finished testing the server, stop it using CTRL+C.

6. Create a System Service for the Server

Creating a system service allows you to start and stop the Factorio server using systemctl commands. It also starts the server automatically when your VPS boots.

Make sure you are in your user account's home directory.

$ cd 

Move the Factorio server files to /opt.

$ sudo mv factorio /opt/

Create a new user called factorio. You will use this account to run the Factorio server, instead of running it as the root user.

$ sudo useradd factorio

Set the new factorio user as the owner of all files in the /opt/factorio directory.

$ sudo chown -R factorio:factorio /opt/factorio

Switch to the factorio user.

$ sudo su factorio

Test the new user account by starting the Factorio server. Check the output and look for any errors.

$ /opt/factorio/bin/x64/factorio --start-server /opt/factorio/savegames/world.zip --server-settings /opt/factorio/server-settings.json 

If there are no errors, your new user account is working. Stop the server using CTRL+C. You can now switch back to your own user account.

$ exit

Create a new service file. This tells systemd how to execute the new service.

$ sudo nano /etc/systemd/system/factorio.service

Paste in the following configuration:

[Unit]
Description=Factorio Server
After=network.target

[Service]
Type=simple
Restart=always
RestartSec=3
User=factorio
ExecStart=/opt/factorio/bin/x64/factorio --start-server /opt/factorio/savegames/world.zip --server-settings /opt/factorio/server-settings.json 

[Install]
WantedBy=multi-user.target

After saving the file, reload the systemd daemon to make sure that it detects the new service.

$ sudo systemctl daemon-reload

Enable the service, so that it starts at boot.

$ sudo systemctl enable factorio.service

Start the service.

$ sudo systemctl start factorio.service

Check the status of the service to ensure that the Factorio server started correctly.

$ sudo systemctl status factorio.service

You can now connect your Factorio client to the VPS's IP address to test the server again. The server will start automatically when your VPS boots. If you need to stop the server, you can use the systemctl stop command.

$ sudo systemctl stop factorio.service

Conclusion

In this article, you installed a Factorio server and set it up to run as a system service. You can learn more about how to run a Factorio multiplayer server on the Factorio website.

Want to contribute?

You could earn up to $600 by adding new articles.