SaferComputing.com

Reference · Local AI servers

LM Studio port 1234 and ComfyUI port 8188: bind address and firewall rules

Check whether LM Studio's server on port 1234 or ComfyUI on port 8188 listens beyond localhost, set --bind and --listen back to 127.0.0.1, and add Windows Defender Firewall rules by port or by executable path.

Published
Updated
Last checked
Applies to
LM Studio and ComfyUI on Windows 11, macOS and Linux
Technical specification
Target artifactLM Studio's API server on TCP port 1234 and ComfyUI's web interface and API on TCP port 8188.
Default behaviourBoth listen on 127.0.0.1 only. LM Studio's Serve on Local Network setting, lms server start --bind 0.0.0.0 or LMS_SERVER_HOST opens its server to the network; ComfyUI's --listen flag with no address listens on every IPv4 and IPv6 address. ComfyUI has no sign-in, and LM Studio's API tokens are off by default.
Safe stateBoth on 127.0.0.1; on LM Studio 0.4.0 or later, the server setting that requires authentication turned on if any other program calls it; inbound firewall rules that block both ports.
Check on WindowsGet-NetTCPConnection -State Listen -LocalPort 1234, 8188 | Select-Object LocalAddress, LocalPort, OwningProcess
Check on Linuxsudo ss -tlnp | grep -E ':(1234|8188)\b'
Check on macOSsudo lsof -nP -iTCP -sTCP:LISTEN | grep -E ':(1234|8188) '
Fixlms server start --port 1234 --bind 127.0.0.1 for LM Studio; start ComfyUI without --listen, or with --listen 127.0.0.1
Fix on WindowsNew-NetFirewallRule -DisplayName 'Block inbound ComfyUI 8188' -Direction Inbound -Protocol TCP -LocalPort 8188 -Action Block

Read the result

  • 127.0.0.1:1234 or 127.0.0.1:8188: this computer only. This is what you want.
  • 0.0.0.0, ::, [::] or * in front of the port: every network interface.
  • No line at all: the server is not running. LM Studio's server listens only after you start it.

LM Studio

  1. Open the Developer page and its server settings, and turn off Serve on Local Network.
  2. On version 0.4.0 or later, turn on the setting that requires authentication for each request. Programs then send a token in an Authorization: Bearer header.
  3. If you start the server from the command line, state the address:
Terminal, using LM Studio's lms tool
lms server start --port 1234 --bind 127.0.0.1

--bind defaults to 127.0.0.1, and LM Studio's documentation warns that any other address exposes the server beyond this computer. The LMS_SERVER_HOST environment variable sets the same thing; check it if the server keeps appearing on the network.

ComfyUI

ComfyUI's address comes from its start-up flags:

FlagWhat it does
noneListens on 127.0.0.1, port 8188
--listen with no addressListens on every IPv4 and IPv6 address
--listen 127.0.0.1This computer only
--port 8188Changes the port
--tls-keyfile and --tls-certfileServe over HTTPS with your own certificate

Look for --listen in whatever starts ComfyUI: the command you type, a shortcut, a batch file or a service definition. Remove it, or give it 127.0.0.1. ComfyUI has no sign-in of its own, so anything that can reach the port can queue work and read results.

Windows Defender Firewall rules

Block by port

Port rules are the simplest and survive program updates:

Windows PowerShell, as Administrator
New-NetFirewallRule -DisplayName 'Block inbound LM Studio 1234' -Direction Inbound -Protocol TCP -LocalPort 1234 -Action Block
New-NetFirewallRule -DisplayName 'Block inbound ComfyUI 8188' -Direction Inbound -Protocol TCP -LocalPort 8188 -Action Block

An explicit block rule takes precedence over any conflicting allow rule.

Block by executable path

First find the program that owns the port, while it is listening:

Windows PowerShell
$c = Get-NetTCPConnection -State Listen -LocalPort 8188 | Select-Object -First 1
(Get-Process -Id $c.OwningProcess).Path

Check whether someone already allowed it, then block it. Program rules need the full path; Windows Defender Firewall does not accept wildcards in them:

Windows PowerShell, as Administrator
Get-NetFirewallApplicationFilter -Program 'FULL_PATH' | Get-NetFirewallRule | Select-Object DisplayName, Enabled, Direction, Action, Profile
New-NetFirewallRule -DisplayName 'Block inbound FULL_PATH' -Direction Inbound -Program 'FULL_PATH' -Action Block

Replace FULL_PATH with the path the first command printed.

Warning ComfyUI runs as python.exe

For ComfyUI, the owning program is a Python interpreter. A rule on that python.exe blocks every script that interpreter runs, and a rule on a versioned path stops matching after an update. Prefer the port rule.

Linux and macOS

On Ubuntu with UFW, insert deny rules above any allow rules: sudo ufw insert 1 deny 8188/tcp, then the same for 1234/tcp. If UFW has no rules yet, ufw insert answers ERROR: Invalid position '1'; use sudo ufw deny 8188/tcp and sudo ufw deny 1234/tcp instead. The macOS firewall decides per application, not per port, so keep both servers on 127.0.0.1.

Troubleshooting

LM Studio still shows 0.0.0.0
  • The server was started before you changed the setting. Stop it and start it again from the Developer page, or with lms server start --bind 127.0.0.1.
  • LMS_SERVER_HOST is set in your environment or in a script that starts the server.
ComfyUI is on 127.0.0.1 but a phone on the same Wi-Fi still opens it

Another program forwards the port: a reverse proxy, a tunnelling tool or a remote-access app. Find what listens on other ports with the commands in the open-port self-audit.

Sources