Managing a dedicated Factorio server in headless mode requires frequent administrative routines: persisting progress before host reboots, notifying players of maintenance windows, executing non-disruptive backups, and tracking active player counts. Directly typing into a screen or tmux session makes automation fragile, which is why Factorio natively implements the Source RCON protocol for remote control across a dedicated network socket.
In this guide, we review how to secure Factorio RCON bindings, trigger live map saves without server downtime, and deploy an automated bash script integrated with Discord webhooks.
Configuring RCON Binding and Credentials#
Factorio activates RCON support via startup parameters passed to the factorio binary. Because standard RCON connections do not use TLS encryption over the wire, it is critical to bind the listener strictly to the local loopback interface 127.0.0.1.
Inspect or append RCON flags to your systemd service configuration (/etc/systemd/system/factorio.service):
cat << 'EOF' > /tmp/factorio_rcon_flags.conf
--rcon-port 27015 \
--rcon-password "StrongSecretKey2026" \
--rcon-bind 127.0.0.1
EOF
cat /tmp/factorio_rcon_flags.conf
The --rcon-bind 127.0.0.1 flag ensures that TCP port 27015 is unreachable by external network scanners and only accepts socket connections initiated from local server scripts.
Triggering Saves and Admin Commands via CLI#
To transmit RCON commands from the Linux shell, use the lightweight CLI client mcrcon or rcon-cli. Install mcrcon and verify connectivity:
sudo apt-get update && sudo apt-get install -y mcrcon
mcrcon -H 127.0.0.1 -P 27015 -p "StrongSecretKey2026" "/players online"
The command returns the list of active players. To trigger an immediate save without stopping the game or introducing tick latency, issue the internal engine command:
mcrcon -H 127.0.0.1 -P 27015 -p "StrongSecretKey2026" "/silent-command game.server_save()"
The /silent-command directive executes native Lua engine logic while suppressing log echoes in player chat windows.
Automated Save Script with Discord Webhook Alerts#
Combine forced RCON saves, world archive validation, and JSON notification delivery to an administrator Discord channel into an automated shell script:
cat << 'EOF' > /opt/factorio/rcon_backup.sh
#!/usr/bin/env bash
set -euo pipefail
RCON_HOST="127.0.0.1"
RCON_PORT="27015"
RCON_PASS="StrongSecretKey2026"
DISCORD_WEBHOOK="https://discord.com/api/webhooks/your_webhook_id/your_token"
SAVE_NAME="world_$(date +%Y%m%d_%H%M%S)"
# Принудительное сохранение мира через RCON
mcrcon -H "$RCON_HOST" -P "$RCON_PORT" -p "$RCON_PASS" "/server-save"
sleep 2
# Оповещение в Discord
PAYLOAD=$(cat <<JSON
{
"username": "Factorio Server Bot",
"content": "Сохранение мира успешно завершено: \`${SAVE_NAME}\`."
}
JSON
)
curl -s -H "Content-Type: application/json" -X POST -d "$PAYLOAD" "$DISCORD_WEBHOOK"
EOF
chmod +x /opt/factorio/rcon_backup.sh
This script issues /server-save, waits briefly for disk flushing to complete, and posts an alert to your monitoring webhook.
Scheduling Automation via Cron#
Register the backup script in the system cron scheduler for routine automated execution:
(crontab -l 2>/dev/null; echo "0 */4 * * * /opt/factorio/rcon_backup.sh >> /var/log/factorio_backup.log 2>&1") | crontab -
crontab -l | grep rcon_backup
Every four hours, the server persists the world state and transmits status telemetry, minimizing the risk of factory progression loss due to hardware crashes.
If you are looking to host Factorio Space Age with secure web-based RCON terminals, real-time UPS/FPS diagnostics, and scheduled cloud snapshots, professional Factorio server hosting delivers instant deployment and high-performance dedicated resources.




