Repository navigation
feat(run): add --listen-addr so a local app can be reached from the network - #1381
Merged
Merged
Conversation
…etwork
`run --local` binds the app to 127.0.0.1 and there is no way to widen it:
LocalRuntimeOptions.ListenAddr is the only field that reaches the runtime's
`runtime_listen_addresses`, and nothing sets it but the default at
applyDefaults. So the app cannot be opened from another machine on the LAN —
the use case being a phone or a second laptop pointing at a dev box, which is
not exotic enough to leave unsupported.
It cannot be fixed after boot either. appContainerParams is sent once, at
startup (StartLocalRuntime); re-sending update_appcontainer_configuration on a
running app fails, because the runtime already holds 127.0.0.1:<port> and
Linux rejects a second bind of the same port on 0.0.0.0:
Runtime port '8095' is already in use
No permission to open socket or another server is already running on
Some(0.0.0.0):8095
So the address has to be right at startup, which means a flag.
The M2EE admin API is a privileged surface — it boots the app, rewrites
configuration and runs actions — so it must not be widened onto the network as
a side effect of widening the app bind. m2eeAdminListenAddr is a constant at
127.0.0.1, used for both the runtime's M2EE_ADMIN_LISTEN_ADDRESSES and mxcli's
own admin client. The client part is not tidiness: 0.0.0.0 is a bind address,
not a destination, so a client dialling it is not portable, and when the admin
bind was simply mirrored the readiness poll timed out with "runtime admin API
did not come up" on a runtime that was up and serving.
The default is unchanged at 127.0.0.1, so nothing behaves differently unless
asked.
Note for callers: the runtime derives ApplicationRootUrl from the bind address
when none is set, and 0.0.0.0 is not a host a browser can ask for. Pair this
with a reachable root URL — an ApplicationRootUrl naming a real host in the
model, or --runtime-setting ApplicationRootUrl=http://<host>:<port>/. The flag
help says so.
Closes #1248
Review follow-ups to mendixlabs#1249: - AppURL is what mxcli dials (health check, screenshots, "App is running at"), but it was built from the bind address: 0.0.0.0 is not a destination and `::` produced the unparseable http://:::8080/. A wildcard now dials loopback of the same family, and IPv6 hosts are bracketed via net.JoinHostPort. - --listen-addr must be an IP address, refused before --detach and the build instead of as a bind failure in the runtime log. - A wildcard bind with no application root URL (model, hub or --runtime-setting) warns at boot, since the runtime derives one from the bind address. The network URLs the app is reachable at are printed after boot. - Flag rows in the run-local skill and docs-site page, CHANGELOG entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBgg5k5sdMTsURKiigb19C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
run --localbinds the app to 127.0.0.1 and there is no way to widen it:LocalRuntimeOptions.ListenAddr is the only field that reaches the runtime's
runtime_listen_addresses, and nothing sets it but the default atapplyDefaults. So the app cannot be opened from another machine on the LAN —
the use case being a phone or a second laptop pointing at a dev box, which is
not exotic enough to leave unsupported.
It cannot be fixed after boot either. appContainerParams is sent once, at
startup (StartLocalRuntime); re-sending update_appcontainer_configuration on a
running app fails, because the runtime already holds 127.0.0.1: and
Linux rejects a second bind of the same port on 0.0.0.0:
So the address has to be right at startup, which means a flag.
The M2EE admin API is a privileged surface — it boots the app, rewrites
configuration and runs actions — so it must not be widened onto the network as
a side effect of widening the app bind. m2eeAdminListenAddr is a constant at
127.0.0.1, used for both the runtime's M2EE_ADMIN_LISTEN_ADDRESSES and mxcli's
own admin client. The client part is not tidiness: 0.0.0.0 is a bind address,
not a destination, so a client dialling it is not portable, and when the admin
bind was simply mirrored the readiness poll timed out with "runtime admin API
did not come up" on a runtime that was up and serving.
The default is unchanged at 127.0.0.1, so nothing behaves differently unless
asked.
Note for callers: the runtime derives ApplicationRootUrl from the bind address
when none is set, and 0.0.0.0 is not a host a browser can ask for. Pair this
with a reachable root URL — an ApplicationRootUrl naming a real host in the
model, or --runtime-setting ApplicationRootUrl=http://:/. The flag
help says so.
Closes #1248