Factorio server operations

Use these instructions on the Factorio host with an account that can run sudo. They assume the Ansible deployment layout.

Important paths

The default game port is UDP 34197. Restarting the service keeps the current world. Resetting the saves or creating a new world changes it.

Check the server

On the server:

sudo systemctl status factorio --no-pager
cd /home/factorio
sudo docker compose ps
sudo docker compose logs --tail=100 factorio

Follow the live log while troubleshooting:

cd /home/factorio
sudo docker compose logs -f factorio

Restart without changing the world

Use this after changing server settings or when the server is misbehaving. It leaves the saves untouched.

On the server:

sudo systemctl restart factorio
sudo systemctl status factorio --no-pager

To stop and start it separately:

sudo systemctl stop factorio
sudo systemctl start factorio

Create a backup

Stopping the server first makes the archive consistent. This backs up saves, configuration, and the other persistent Factorio data.

On the server:

sudo install -d -o factorio -g factorio -m 0750 /home/factorio/backups
sudo systemctl stop factorio
sudo tar -C /home/factorio \
  -czf "/home/factorio/backups/factorio-data-$(date +%Y%m%d-%H%M%S).tar.gz" \
  data
sudo systemctl start factorio
sudo systemctl status factorio --no-pager

List the available archives:

sudo ls -lh /home/factorio/backups

These backups are on the same disk as the server. They are useful for trying different worlds, but do not protect against loss of the host itself.

Restore a specific backup

Replace BACKUP_FILE with the archive you want, for example factorio-data-20260916-203000.tar.gz.

Inspect it first:

sudo tar -tzf "/home/factorio/backups/BACKUP_FILE" | head -30

Restore it on the server:

sudo systemctl stop factorio
sudo mv /home/factorio/data \
  "/home/factorio/data.before-restore-$(date +%Y%m%d-%H%M%S)"
sudo tar -C /home/factorio \
  -xzf "/home/factorio/backups/BACKUP_FILE"
sudo chown -R factorio:factorio /home/factorio/data
sudo systemctl start factorio
sudo systemctl status factorio --no-pager

The old data directory is moved aside rather than deleted, so the restore can be undone if needed. Use the same Factorio version that created the save.

Reset the world

This removes the active saves from the server's save directory while keeping a rollback copy. It does not remove the server password or other configuration.

On the server:

sudo systemctl stop factorio
sudo mv /home/factorio/data/saves \
  "/home/factorio/data/saves.before-reset-$(date +%Y%m%d-%H%M%S)"
sudo install -d -o factorio -g factorio -m 0750 /home/factorio/data/saves
sudo systemctl start factorio
sudo systemctl status factorio --no-pager

Whether an empty saves directory automatically creates a new world depends on the Compose command and image configuration. If it does not, inspect the configured create/start command:

cd /home/factorio
grep -nE 'SAVE|CREATE|START|factorio' compose.yaml .env 2>/dev/null

Use the world-creation command defined there, then check the logs for the new save name.

Change the world

Return to an earlier world

Restore the corresponding factorio-data-*.tar.gz archive using the restore procedure above.

Create a new world with different map generation

Map-generation settings only affect a newly created world. Changing them does not alter an existing save.

  1. Stop the service.
  2. Edit /home/factorio/data/config/map-gen-settings.json.
  3. Move the current saves directory aside using the reset procedure.
  4. Create the new world using the command configured in compose.yaml.
  5. Start the service and verify the new world in the logs.

Keep server-settings.json unless you intentionally want to change the server name, description, visibility, password, or related settings.

Switch to a separate save ZIP

Copy the save ZIP into the saves directory, then select it using the save-name option defined by the deployment's compose.yaml or .env.

On the server:

sudo cp /path/to/world.zip /home/factorio/data/saves/
sudo chown factorio:factorio /home/factorio/data/saves/world.zip
cd /home/factorio
grep -nE 'SAVE|START|factorio' compose.yaml .env 2>/dev/null
sudo systemctl restart factorio

Map-generation settings are not applied to an existing save.

Quick recovery after an AI experiment

  1. Stop the server if it is still running.
  2. Reset the saves directory, or restore a chosen backup.
  3. Start the service.
  4. Check the service status and Compose logs.
  5. Reconnect using the same server address, Factorio version, and mods.

Back to Factorio