Skip to content

Read rcon password from settings.json and bind rcon to localhost - #135

Merged
grilledham merged 2 commits into
Refactorio:developfrom
lex:rcon-password-from-settings
Oct 22, 2026
Merged

grilledham merged 2 commits into
Refactorio:developfrom
lex:rcon-password-from-settings

Conversation

@lex

@lex lex commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

The wrapper started Factorio with a hardcoded rcon password, so every server used the same password, and that password is in this repo. It also used --rcon-port, which makes Factorio listen for rcon on all interfaces. Since #132 the rcon arguments are also added on Linux.

Changes

  • Add an optional rcon_password setting to the wrapper's settings.json (also added to settings.template.json).
  • If it's empty or missing, the wrapper generates a random password each time it starts. Existing settings.json files keep working without changes.
  • The wrapper refuses to start if the password contains whitespace or quotes, because it's passed to Factorio on the command line.
  • The rcon arguments are now added after the "Starting factorio process" log line, so the password no longer ends up in the wrapper log.
  • Use --rcon-bind 127.0.0.1:<port> instead of --rcon-port <port>, so rcon is only reachable from the same machine. The wrapper already connects to 127.0.0.1, so nothing else changes. Remote rcon access is no longer possible; use an SSH tunnel if you need it.

Testing

  • The wrapper builds. The project's PreBuild step uses cmd syntax, so on Linux I built a copy with that step removed.
  • I ran a headless Factorio 2.0 server locally with each flag:
    • --rcon-port 34299: Starting RCON interface at IP ADDR:({0.0.0.0:34299}), listening on 0.0.0.0:34299
    • --rcon-bind 127.0.0.1:34299: Starting RCON interface at IP ADDR:({127.0.0.1:34299}), listening on 127.0.0.1:34299 only. The game's UDP port is unaffected.
  • The wrapper itself hasn't been run end to end against a live server.

🤖 Generated with Claude Code

lex and others added 2 commits October 22, 2026 23:11
The rcon password was a hardcoded constant, so every server started with
the same, publicly known password. Since Refactorio#132 this also applies on Linux.

Add an optional rcon_password setting to the wrapper's settings.json. If
it's empty or missing, a random password is generated each time the
wrapper starts, so existing settings files keep working. The password is
also no longer written to the wrapper log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--rcon-port makes Factorio listen for rcon on all interfaces. The wrapper
only connects to rcon on 127.0.0.1, so bind it there and keep it off the
public network.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lex lex changed the title Read rcon password from settings.json Read rcon password from settings.json and bind rcon to localhost Oct 22, 2026
@grilledham
grilledham merged commit 152fa12 into Refactorio:develop Oct 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants