Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save petergi/fbe6b1749edccee2b993e03a70b237a9 to your computer and use it in GitHub Desktop.

Select an option

Save petergi/fbe6b1749edccee2b993e03a70b237a9 to your computer and use it in GitHub Desktop.
Access LM Studio API running on Windows from another device (Mac) on the same network.

LM Studio Remote Access Setup (Windows → Mac)

Overview

Access LM Studio API running on Windows from another device (Mac) on the same network.


1. Find Listening Ports (Windows PowerShell)

(Get-NetTCPConnection -State Listen | Select-Object -ExpandProperty LocalPort -Unique | Sort-Object) | ConvertTo-Json -Compress

2. Check What's Using a Specific Port

Get-NetTCPConnection -LocalPort 15100 | Select-Object LocalAddress, LocalPort, State, @{Name='Process';Expression={(Get-Process -Id $_.OwningProcess).ProcessName}}

Good output: LocalAddress should be 0.0.0.0 (accepts all connections) Bad output: 127.0.0.1 (localhost only — reconfigure the app)


3. Check Firewall Rules for a Port

Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -eq 15100 } | Get-NetFirewallRule | Where-Object { $_.Enabled -eq 'True' } | Select-Object DisplayName, Direction, Action, Enabled | Format-Table -AutoSize

No output = no rule exists (inbound blocked by default).


4. Create Firewall Rules (Allow Inbound + Outbound)

New-NetFirewallRule -DisplayName "Allow Port 15100 Inbound" -Direction Inbound -Protocol TCP -LocalPort 15100 -Action Allow; New-NetFirewallRule -DisplayName "Allow Port 15100 Outbound" -Direction Outbound -Protocol TCP -LocalPort 15100 -Action Allow

5. Verify Firewall Rules Were Created

Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -eq 15100 } | Get-NetFirewallRule | Select-Object DisplayName, Direction, Action, Enabled | Format-Table -AutoSize

6. Remove Firewall Rules (If Needed)

Remove-NetFirewallRule -DisplayName "Allow Port 15100 Inbound"; Remove-NetFirewallRule -DisplayName "Allow Port 15100 Outbound"

7. Find Windows Machine's Real IP

Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.IPAddress -notlike "127.*" -and $_.IPAddress -notlike "169.*" } | Select-Object InterfaceAlias, IPAddress

Use the Wi-Fi or Ethernet IP (e.g., 192.168.2.177) Don't use: VirtualBox (192.168.56.x) or Hyper-V (172.x.x.x) IPs


8. Test Connectivity From Mac

Test port is open:

nc -zv 192.168.2.177 15100

Test API responds:

curl --max-time 30 http://192.168.2.177:15100/v1/models

Test chat completion:

curl --max-time 300 http://192.168.2.177:15100/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "qwen/qwen3-coder-30b", "messages": [{"role": "system", "content": "You answer only in rhymes."}, {"role": "user", "content": "What is your favorite color?"}]}'

9. See All Listening Ports With Process Names

Get-NetTCPConnection -State Listen | Select-Object LocalPort, @{Name='PID';Expression={$_.OwningProcess}}, @{Name='Process';Expression={(Get-Process -Id $_.OwningProcess).ProcessName}}, @{Name='Path';Expression={(Get-Process -Id $_.OwningProcess).Path}} | Sort-Object LocalPort | Format-Table -AutoSize

10. Check Firewall Status

Get-NetFirewallProfile | Select-Object Name, Enabled, DefaultInboundAction, DefaultOutboundAction | Format-Table -AutoSize

11. List All Listening Ports (Alternative Methods)

Linux/macOS (zsh):

netstat -an 2>/dev/null | grep LISTEN | grep -oE ':\d+' | sed 's/://' | sort -nu | paste -sd, - | sed 's/^/[/;s/$/]/'

Windows (from CMD):

powershell -Command "(Get-NetTCPConnection -State Listen | Select-Object -ExpandProperty LocalPort -Unique | Sort-Object) | ConvertTo-Json -Compress"

Troubleshooting

Symptom Cause Fix
nc times out Wrong IP (VirtualBox/Hyper-V) Use Wi-Fi/Ethernet IP
nc connection refused Firewall blocking or service not running Add firewall rule, check service
API hangs Large model, slow inference Wait longer, use smaller model
LocalAddress is 127.0.0.1 App only accepts localhost Reconfigure app to bind to 0.0.0.0
PowerShell command freezes Inefficient firewall query Use Get-NetFirewallPortFilter first

Common IPs to Ignore

IP Pattern What It Is
192.168.56.x VirtualBox Host-Only
172.x.x.x Hyper-V / WSL
127.0.0.1 Localhost
169.254.x.x APIPA (no network)

Common Ports Reference

Port Service
22 SSH
135, 139, 445 Windows Core (RPC, NetBIOS, SMB)
3389 Remote Desktop (RDP)
5800, 5900 VNC
5985, 47001 WinRM
9222 Chrome DevTools
15100 LM Studio (default)
27015 Steam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment