Before switching on LM Studio's Serve on Local Network so a second office machine can use the server, what do you configure and why?
answer
- localhost is the only fence
- open by default
- one token per client, copied once
- Bearer header, or x-api-key
- cross-origin access is separate
basics
~20 sServe on Local Network exposes a server that by default needs no authentication, so first switch on Require Authentication (LM Studio 0.4.0+), issue each client its own API token with only the permissions it needs, and leave Enable CORS off.
solid answer
~50 sBy default the server binds `127.0.0.1`, and that bind is its only protection, because **LM Studio does not require authentication** for API requests. **Serve on Local Network** makes it bind a non-localhost address, so every device on the network can call it; the docs warn about this and recommend authentication. So switch on **Require Authentication** in Server Settings (LM Studio 0.4.0 or newer), then use **Manage Tokens** to create a named token per client with only the permissions it needs, copying each one at creation because it is not shown again. Clients send it as `Authorization: Bearer <token>`, which is where the OpenAI SDK puts `api_key`; `/v1/messages` also accepts `x-api-key`, and LM Studio's SDKs read `LM_API_TOKEN`. **Enable CORS** is a separate switch that only browser apps on other origins need. **Allow calling servers from mcp.json** requires authentication and can reach local data, so leave it off unless needed.
code
bash · 9 lines# On the second machine; the address is the one LM Studio shows once Serve on Local Network is on
export LM_API_TOKEN="<token copied from Manage Tokens>"
# Should be rejected now that Require Authentication is on
curl -i http://192.168.1.20:1234/v1/models
# Should succeed
curl -i http://192.168.1.20:1234/v1/models \
-H "Authorization: Bearer $LM_API_TOKEN"go deeper
Recall that LM Studio's server is unauthenticated and localhost-only by default, and that Serve on Local Network removes the localhost limit.
Explain how API tokens are created, shown once, and sent by OpenAI-style, Anthropic-style and LM Studio SDK clients.
Demonstrate the hardening order: authentication before exposure, a token per client, CORS and MCP access off unless needed, then a negative test from the remote machine.
Judge when a workstation server reached over the LAN stops being acceptable and the team needs a dedicated, managed inference service instead.
## What changes when the server leaves localhost Out of the box, LM Studio's server binds **`127.0.0.1`**: only programs on the same machine can open a connection. That bind is doing all the security work, because **by default LM Studio does not require authentication for API requests**. Anyone who can reach the port can list models, run inference, and use the native REST API to load, unload and even download models. **Serve on Local Network** is the Server Settings switch that changes the bind to a non-localhost address, so other devices on the same network can use the API, for example a second office machine, a thin laptop, or a small device. The docs are blunt: any bind other than `127.0.0.1` exposes the server beyond localhost, and they recommend enabling authentication first. ## The order to do it in 1. Switch on **Require Authentication** in the Developer tab's Server Settings. It needs **LM Studio 0.4.0 or newer**. From then on, API clients must present a valid API token in the `Authorization` header, and requests through the REST API and LM Studio's Python and TypeScript SDKs need one too. 2. Open **Manage Tokens**, click **Create Token**, give it a name and choose its permissions. Create **one token per client** so you can scope and revoke them separately. 3. **Copy the token immediately**: it is not shown again. Losing it means deleting it and creating a new one. 4. Configure the client: OpenAI SDKs send their `api_key` as a Bearer token; the Anthropic-style `/v1/messages` route accepts either `Authorization: Bearer` or `x-api-key`; LM Studio's own SDKs read the `LM_API_TOKEN` environment variable or take the token as a constructor argument. 5. Only now switch on **Serve on Local Network**, and give the remote machine the new address that the server shows instead of `localhost`. 6. Check from the second machine that a request **without** a token is rejected and one **with** a token succeeds. ## The switches side by side | Setting | What it controls | Safe choice for a LAN server | |---|---|---| | Server Port | the port the API listens on (1234 by default) | keep, or move it if a host firewall rule expects another | | Require Authentication | whether a valid API token is required | **on** before any network exposure | | Serve on Local Network | bind beyond localhost | on, only after authentication | | Enable CORS | lets web apps on other origins call the API | off unless a browser app needs it | | Allow per-request MCPs | lets clients attach remote MCP servers that are not in your `mcp.json` | off unless a client needs it | | Allow calling servers from mcp.json | lets clients use the MCP servers you configured in the app | off; it **requires** Require Authentication and can reach your files or private data | **Enable CORS** is often confused with network access. It does not open the server to other machines; it lets a page served from a different origin call the API from a browser. The docs attach the same warning to it as to the network bind. ## What tokens do and do not give you - **Per-client identity and revocation**: delete one token in the API Tokens modal and only that client loses access. - **Scoped permissions**: each token carries the permissions chosen when it was created, and they can be edited later. - **No transport encryption by themselves**: the documented URLs are plain `http://`, so a token travels across the network in the clear unless something else on your network adds encryption. - **No multi-user serving guarantees**: authentication decides who may call; it does not turn a workstation into a hardened shared inference service. ## Common mistakes - Turning on Serve on Local Network first and "adding auth later". - Sharing one personal token with everyone, so revoking one person locks out all of them. - Turning on Enable CORS to "fix" a remote machine that cannot connect, when the network bind or a firewall is the real issue. - Enabling mcp.json access for convenience on a server other people can reach. API tokens, Require Authentication and the native `/api/v1` REST API all arrived with LM Studio 0.4.0; on older releases the only protection is keeping the server on localhost.
- Why give the second machine its own token instead of sharing yours?Each token has its own name and permissions, and tokens are deleted one at a time in the API Tokens modal. A per-client token can be scoped to what that client needs and revoked without breaking anyone else; a shared one can only be revoked for everybody.
- A browser chat UI served from another origin is blocked even with a valid token. What is missing?Cross-origin browser calls need **Enable CORS**, a separate Server Settings switch from authentication and from Serve on Local Network. Turn it on only for that need, since the docs warn it can expose the server, and keep Require Authentication on.
- LM Studio's server requires an API token out of the box.
- Serve on Local Network is safe by itself because only trusted devices share the office network.
- Enable CORS is the switch that lets another machine on the LAN reach the server.
- A token you forgot to copy can be viewed again in the Manage Tokens modal.
- The Anthropic-style route ignores x-api-key and only reads a Bearer header.
Assumes LM Studio 0.4.0 or newer, the release that added Require Authentication and API tokens; older releases have no token check.