A llama.cpp server listener decides which clients can reach the local API and web UI. The default loopback listener keeps access on the same machine, while a LAN client, container, or reverse proxy needs an explicit bind address and a TCP port that is not already used.
llama-server can change its listener address and TCP port at startup. A loopback bind accepts only same-host clients, an all-interfaces bind accepts traffic arriving on any IPv4 interface, and a specific LAN address restricts the listener to that one interface when the operating system owns it.
Binding to all interfaces does not add authentication or firewall rules. Keep private model servers on loopback unless another machine or proxy must connect, and add the model source option already used for inference when the listener should serve a model immediately.
Steps to set llama.cpp server host and port:
- Choose the bind address and TCP port.
Use 127.0.0.1 for same-machine clients, 0.0.0.0 for all IPv4 interfaces, or the server's specific LAN address when only one interface should accept requests. The port must be unused on the host.
- Start llama-server with the selected host and port.
$ llama-server --host 0.0.0.0 --port 9091 llama_server: starting server in router mode llama_server: listening on http://0.0.0.0:9091
Router mode starts when no model source is supplied. Add --model /path/to/model.gguf, --hf-repo owner/model:quant, or --models-dir /path/to/models to the same startup command when the server should load a model.
Do not bind to 0.0.0.0 on an untrusted network unless firewall rules, a reverse proxy, or --api-key limits who can connect.
- Request the health endpoint through the selected port.
$ curl -sS -i http://127.0.0.1:9091/health HTTP/1.1 200 OK Keep-Alive: timeout=5, max=100 Content-Type: application/json; charset=utf-8 Server: llama.cpp Content-Length: 15 Access-Control-Allow-Origin: {"status":"ok"}Use the server's LAN address or reverse-proxy hostname instead of 127.0.0.1 when checking access from another machine.
Related: How to check llama.cpp server health
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.