SaferComputing.com

Reference · Local AI servers

vLLM port 8000: host binding, --api-key and the endpoints it leaves open

vllm serve listens on every IPv4 interface on port 8000 unless --host says otherwise, and --api-key or VLLM_API_KEY guards only some paths. Check the binding, pin it to 127.0.0.1 and put a proxy in front.

Published
Updated
Last checked
Applies to
vLLM's OpenAI-compatible server, started with vllm serve or from the vllm/vllm-openai Docker image
Technical specification
Target artifactvLLM's OpenAI-compatible HTTP server, started with vllm serve, on TCP port 8000 unless --port changes it.
Default behaviourWith no --host, it binds an empty host address, which means every IPv4 interface, and logs it as 0.0.0.0. There is no API key until you set --api-key or VLLM_API_KEY, and even then the key covers only some paths, such as those under /v1; /invocations, /metrics, /tokenize, /health and /version answer without it.
Safe stateStarted with --host 127.0.0.1; any access from other machines goes through a reverse proxy that allows only the endpoints you need and adds its own authentication; an API key set as well; VLLM_SERVER_DEV_MODE unset; no --grpc-port reachable from untrusted networks.
Check on Linuxsudo ss -tlnp | grep -E ':8000\b'
Check in Dockerdocker ps --format 'table {{.Names}}\t{{.Ports}}'
Check from another devicecurl --max-time 5 -i http://SERVER_IP:8000/version
Fix on Linuxadd --host 127.0.0.1 to the vllm serve command
Fix in Dockerpublish with -p 127.0.0.1:8000:8000, never -p 8000:8000

Read the result

What you seeMeaning
0.0.0.0:8000 in ssEvery IPv4 interface: vLLM's default when --host is not given
127.0.0.1:8000This computer only
0.0.0.0:8000->8000/tcp in docker psPublished on every host address, as in vLLM's documented Docker command
127.0.0.1:8000->8000/tcpOnly the host itself can connect

vLLM's command-line reference lists no default for --host. Its server code builds the listening address as (args.host or "", args.port); Python binds an empty host to INADDR_ANY, every IPv4 interface, and vLLM's start-up log reports the address as http://0.0.0.0:8000.

From another device, a status line in reply to /version means the server answers from there, with or without an API key, because /version is not protected. "Connection refused" or a timeout means it does not.

What --api-key protects

--api-key, or the VLLM_API_KEY environment variable, makes clients send the key as a Bearer token, but only on some paths. vLLM's security documentation says not to rely on it alone.

  • Needs the key: paths under /v1, /v2, /inference and /cohere, such as /v1/chat/completions, /v1/embeddings and /v1/models.
  • Answers without it: /invocations, a SageMaker-compatible endpoint that routes to the same inference functions as /v1; /generative_scoring, /pooling, /classify, and /score and /rerank outside /v1; /metrics, with model, throughput, queue and KV-cache statistics; /kv_event_sources, /tokenize, /detokenize, /health, /ping, /version and /load; and operational endpoints such as /pause, /abort_requests and /update_weights when the model supports text generation.

So anyone who can reach the port can still run the model through /invocations, key or no key. The key is a second layer; where the server listens is the first.

Linux, on the vLLM server
curl --max-time 5 -H "Authorization: Bearer YOUR_KEY" http://127.0.0.1:8000/v1/models

Generate a key with openssl rand -hex 32, and pass it in VLLM_API_KEY rather than with --api-key, so it does not appear in the server's command line.

Keep it on 127.0.0.1

vllm serve
Linux, as the user who runs vLLM
vllm serve NousResearch/Meta-Llama-3-8B-Instruct --host 127.0.0.1 --port 8000

Use your own model name in place of the example. Then run the check again; it should show 127.0.0.1:8000.

Docker (vllm/vllm-openai)

vLLM's Docker documentation publishes the port with -p 8000:8000, on every host address. This is the same command with the port on the loopback address and the key passed in from your shell:

Linux, as a user in the docker group
docker run --runtime nvidia --gpus all -v ~/.cache/huggingface:/root/.cache/huggingface --env "HF_TOKEN=$HF_TOKEN" --env "VLLM_API_KEY=$VLLM_API_KEY" -p 127.0.0.1:8000:8000 --ipc=host vllm/vllm-openai:latest --model Qwen/Qwen3-0.6B

Inside the container vLLM still listens on all of the container's addresses; the host side of -p decides who can connect. Ports published by Docker bypass UFW; see Docker published ports.

Reaching it from another computer
Your laptop
ssh -N -L 8000:127.0.0.1:8000 USER@AI_SERVER

While the tunnel runs, http://127.0.0.1:8000/v1 on the laptop reaches the server. For several users, vLLM's security documentation recommends a reverse proxy that explicitly allows only the endpoints you want to expose, and adds authentication, rate limiting and logging.

Settings that open more

  • --grpc-port: starts a gRPC service on that port, bound to the same host address as the HTTP server. vLLM's documentation says the gRPC interface has no authentication, authorization or encryption, and must not be exposed to the internet or untrusted clients. Without the option, no gRPC server starts.
  • VLLM_SERVER_DEV_MODE=1: adds development endpoints, including /collective_rpc, which executes arbitrary RPC methods on the engine. The documentation says never to set it in production.
  • Several machines: communication between the nodes of a multi-node deployment is insecure by default, and PyTorch's TCPStore listens on all network interfaces. Set VLLM_HOST_IP to a specific address and keep the nodes on a dedicated, isolated network.
  • --allowed-local-media-path: lets API requests read local images or videos from the folders you name. It is empty by default; keep it empty on any server other people can reach.
  • --allowed-origins: cross-origin browser access is off by default. Leave it empty unless a specific web app needs it.

Troubleshooting

Requests without the key are refused, but /version still answers

That is expected: the key covers only some paths. Keep the port off the network, and filter paths in a reverse proxy if other machines need it.

The key is set, but the check still shows 0.0.0.0

The key does not change where vLLM listens. Add --host 127.0.0.1, or publish the Docker port on 127.0.0.1.

Something else answers on port 8000

Another program owns the port; the last column of sudo ss -tlnp names it. Chroma's server also uses port 8000 by default; see Qdrant and Chroma.

Sources