Skip to content

Default Studio host to 127.0.0.1 and prompt before auto-start#5267

Merged
rolandtannous merged 1 commit into
mainfrom
feature/host-local-permission-autostart
May 4, 2026
Merged

Default Studio host to 127.0.0.1 and prompt before auto-start#5267
rolandtannous merged 1 commit into
mainfrom
feature/host-local-permission-autostart

Conversation

@rolandtannous
Copy link
Copy Markdown

@rolandtannous rolandtannous commented May 4, 2026

Summary

Resolves #4684 and supersedes #4864.

Credit to @Bedrovelsen for initially raising the issue and writing the original fix in #4864. This PR carries the same goals forward and is rebased onto current main to clear the studio/backend/run.py conflict that #4864 picked up as main evolved (notably the addition of --api-only and llama_parallel_slots to run.py's argparse handling).

Studio previously bound to 0.0.0.0 (all interfaces) by default, and the installer silently auto-started a server at the end of install — exposing the service on the network without user consent and contradicting the documented privacy-first / 100% local guarantee.

Changes

  • studio/backend/run.py: run_server() and argparse --host default to 127.0.0.1. (No _make_argument_parser() extraction, since main has since added --api-only/llama_parallel_slots to that block — the default-value change alone meets the security goal.)
  • unsloth_cli/commands/studio.py: typer --host default to 127.0.0.1 in both studio_default() and run() (the unsloth studio run one-liner). security: default Studio host to 127.0.0.1 and prompt before auto-start #4864 only touched the first.
  • install.sh: drop -H 0.0.0.0 from the generated ~/.local/share/unsloth/launch-studio.sh template; replace silent auto-start with a [Y/n] prompt; add a (add -H 0.0.0.0 to allow network / cloud access) note in the manual hint.
  • install.ps1: drop -H 0.0.0.0 from the PowerShell launcher template; replace silent auto-start with a Read-Host [Y/n] prompt; same note.
  • studio/setup.sh: drop -H 0.0.0.0 from the post-setup launch: hint and add the cloud/network note. (Not in security: default Studio host to 127.0.0.1 and prompt before auto-start #4864 — without this, the post-setup hint contradicted the new default.)
  • README.md: simplify Launch examples to unsloth studio -p 8888; add a note that -H 0.0.0.0 is available for cloud/LAN use. -p 8888 is kept in user-visible hints since it documents the default port (only -H 0.0.0.0 is the security concern being removed).

Users who need all-interfaces binding (cloud VMs, LAN sharing) can still pass -H 0.0.0.0 explicitly.

Tauri impact

None. Both installers exit on the --tauri early-return well before the auto-start prompt block, and the Tauri runtime path uses --api-only (Tauri parses the TAURI_PORT={port} line and connects via 127.0.0.1 regardless of bind host). Desktop shortcuts (.desktop / .lnk / .app) now invoke unsloth studio and bind loopback by default — correct desktop behaviour.

Tests (TDD)

  • studio/backend/tests/test_host_defaults.py — AST inspection of run_server() parameter default and argparse --host default. Walks the whole module so the assertions hold whether the parser lives in __main__ or a helper.
  • tests/studio/test_cli_studio_defaults.py — AST inspection of the typer Option default for both studio_default() and run().
  • tests/sh/test_install_host_defaults.sh — static analysis of install.sh, install.ps1, studio/setup.sh, and README.md.

Test plan

  • Linux interactive: ./install.sh --local → prompt appears, Enter launches Studio bound to 127.0.0.1:8888, n prints manual hint and exits cleanly.
  • unsloth studio (no flags) binds to 127.0.0.1:8888.
  • unsloth studio -H 0.0.0.0 -p 8888 still binds to all interfaces.
  • Tauri install (--tauri) skips the prompt and finishes as before. Notified Mugi. Mugi to adjust
  • pytest studio/backend/tests/test_host_defaults.py tests/studio/test_cli_studio_defaults.py passes.
  • bash tests/sh/test_install_host_defaults.sh passes.

Studio bound to 0.0.0.0 by default and the installer silently auto-started
a server at end of install, exposing it on the network without consent and
contradicting the privacy-first / local-only guarantee.

- studio/backend/run.py: run_server() and argparse --host default to 127.0.0.1
- unsloth_cli/commands/studio.py: studio_default() and run() --host default to 127.0.0.1
- install.sh: drop -H 0.0.0.0 from generated launcher template; replace silent
  auto-start with a [Y/n] prompt; add cloud/network note to manual hint
- install.ps1: drop -H 0.0.0.0 from PowerShell launcher template; replace
  silent auto-start with a Read-Host [Y/n] prompt; add cloud/network note
- studio/setup.sh: drop -H 0.0.0.0 from launch hint; add cloud/network note
- README.md: simplify launch examples to `unsloth studio -p 8888`; note
  -H 0.0.0.0 is available for cloud/LAN use

Tests:
- studio/backend/tests/test_host_defaults.py
- tests/studio/test_cli_studio_defaults.py
- tests/sh/test_install_host_defaults.sh
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request changes the default host binding for Unsloth Studio from 0.0.0.0 to 127.0.0.1 across the backend, CLI, and installation scripts to ensure a "privacy-first" local experience. Documentation and setup scripts have been updated to reflect this change, including new interactive prompts in the installers and instructions for users who require network access. Additionally, new tests using AST parsing have been added to verify these defaults. I have no feedback to provide.

@rolandtannous
Copy link
Copy Markdown
Author

tests

colab.test.mp4
local.test.mp4
Screenshot 2026-05-04 at 12 41 10 PM Screenshot 2026-05-04 at 12 54 51 PM Screenshot 2026-05-04 at 12 47 29 PM

merging

@rolandtannous rolandtannous marked this pull request as ready for review May 4, 2026 09:03
@rolandtannous rolandtannous merged commit 35ab5da into main May 4, 2026
6 checks passed
@rolandtannous rolandtannous deleted the feature/host-local-permission-autostart branch May 4, 2026 09:03
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.

[Feature] Change default host to 127.0.0.1 instead of 0.0.0.0 / Remove installation auto start instance without notice

1 participant