New Tool Radar

Local AI

How to Fix Jan’s Local API Server Errors: Refused, 401, 404

Read Jan's local API server errors — connection refused, no model, 401, 404, CORS — and fix each one at its cause.

Schematic diagram with four steps: run curl against /v1/models, read the error, match it to its cause, then fix the server setting and retry.

A Jan API call that fails tells you which thing is wrong, if you read the error: connection refused means the server is not running, 401 means the key is wrong or missing, 404 means the model or route is wrong, and a CORS error means the browser is blocked. Each has a different fix.

Match the error to its fix

Connection refused: the server is not running — start the local API server in Jan and check it listens on port 1337. No model: no model is loaded — load one in Jan first. 401: the API key is wrong or missing — check the Bearer header against the key in Jan’s settings. 404: the route or model name is wrong — check the /v1 prefix and the model identifier. CORS: the browser is blocking the call — check the trusted hosts and the calling origin.

curl http://127.0.0.1:1337/v1/models
# connection refused -> server not running
# 401 -> API key wrong or missing
# 404 -> route or model name wrong

Test with curl before blaming your app: curl shows you the raw status and body, while an app hides both behind its own error message. Fix the server-side cause first — the client code is usually fine.

Try it: four checks

Check What you should see If you do not see it
Server running curl /v1/models answers Start the server if refused
Model loaded A model is loaded in Jan Load one before calling
Key right The Bearer key matches Jan’s settings A 401 means the key
Route right The /v1 prefix and model name are correct A 404 means the route

Expected result. We checked the Jan local API server docs, which list the server’s errors: no model, connection refused, 401, 404 and CORS, and give the default base http://127.0.0.1:1337/v1. We did not reproduce any error on this machine.

Limits

This guide covers the documented errors only. An error not listed here needs the server log. We did not test any fix ourselves.

Sources

See all