Connect Open WebUI to LM Studio in Docker: Setup and Connection Fixes
To connect Open WebUI running in Docker to LM Studio on the host, add http://host.docker.internal:1234/v1 as an OpenAI-compatible connection. Before saving the connection, confirm the same container can reach LM Studio’s model-list endpoint.
1. Verify LM Studio on the host
In LM Studio, load a small model and start the server from the Developer screen. Confirm the port and run this check from the host:
curl --fail-with-body http://127.0.0.1:1234/v1/modelsWhen authentication is enabled, send the configured bearer token. Record the model ID and verify you can generate a short reply in LM Studio. Check the server’s bind address separately. A service listening only on loopback may be unreachable from a bridged Linux container even though this host test succeeds.
2. Make the host reachable from Docker
Docker Desktop normally supplies host.docker.internal. On Linux Docker Engine, add the host gateway mapping to the Open WebUI service and recreate that container with its existing named data volume.
services:
open-webui:
extra_hosts:
- "host.docker.internal:host-gateway"This is a fragment to add to an existing Compose service. On Linux, the mapping resolves the hostname. LM Studio must also listen on an address reachable from that container. If you enable serving on the local network, restrict access to the intended network and use LM Studio API authentication where supported. Keep port 1234 off public interfaces.
3. Check the API from inside Open WebUI
docker exec open-webui python -c "import urllib.request; print(urllib.request.urlopen('http://host.docker.internal:1234/v1/models', timeout=5).read().decode())"Replace open-webui with your container name. Use an authenticated request if the API is protected. A successful response contains model IDs. A DNS error points to host resolution, a refused connection points to port or binding, and an HTTP 401 means the container can reach the service and needs credentials.
4. Save the provider connection and send a message
- Open Open WebUI’s admin connection settings and add an OpenAI-compatible provider.
- Enter
http://host.docker.internal:1234/v1, or the actual reachable host address followed by/v1. - Set the API key to the server’s configured token when authentication is enabled.
- Save and refresh the model selector. Select the intended model and send a short message. Check LM Studio logs to verify the request reached it.
For managed deployments, consult Open WebUI’s environment configuration for OPENAI_API_BASE_URLS and persisted connections. A previously saved admin setting can matter when you change the environment and recreate a container.
Common failures and what they mean
| Problem | Fix |
|---|---|
localhost fails inside Docker | Use the host gateway on a bridged network. The container’s own loopback is a separate network namespace. |
| Host works, container times out | Check listen address and firewall from the container’s network. Test the path before changing model settings. |
| Connection saves, model list is empty | Check /v1/models from the container, verify the provider is enabled and inspect any model ID filters. |
| Models appear, replies fail | Check the selected model ID and LM Studio logs. Try short text without attachments or tools. |
FAQ
Should I use the Ollama connection type?
For this setup, use OpenAI-compatible. The Open WebUI and Ollama guide uses a different provider path and port.
What if Open WebUI is on a different computer?
Use the LM Studio host’s reachable private address. Test it from the Open WebUI container and configure the server and firewall for that client. See the LM Studio developer docs for API options.
