mudler/LocalAI · error · Error
status: HTTP ${statusRes.status}
Error message
status: HTTP ${statusRes.status} What it means
Thrown by the Middleware dashboard's fetchAll() when GET /api/middleware/status returns a non-2xx status. The status endpoint is treated as fatal (it defines the page), while /api/pii/events and /api/router/decisions failures are silently ignored, so this error fires only when the middleware status route itself fails. In silent background polls the error is swallowed (no toast); on the initial load it surfaces as a toast.
Source
Thrown at core/http/react-ui/src/pages/Middleware.jsx:84
const initialTab = searchParams.get('tab') || localStorage.getItem('middleware-tab') || 'filtering'
const [activeTab, setActiveTab] = useState(TABS.some(t => t.id === initialTab) ? initialTab : 'filtering')
const selectTab = (id) => {
setActiveTab(id)
localStorage.setItem('middleware-tab', id)
setSearchParams({ tab: id })
}
// silent=true on background polls: skips the loading spinner and
// suppresses toast spam if the server is briefly unreachable.
const fetchAll = useCallback(async (silent = false) => {
if (!silent) setLoading(true)
try {
const [statusRes, eventsRes, decisionsRes] = await Promise.all([
fetch(apiUrl('/api/middleware/status')),
fetch(apiUrl('/api/pii/events?limit=100')),
fetch(apiUrl('/api/router/decisions?limit=100')),
])
if (!statusRes.ok) throw new Error(`status: HTTP ${statusRes.status}`)
const statusData = await statusRes.json()
setStatus(statusData)
if (eventsRes.ok) {
const data = await eventsRes.json()
setEvents(data.events || [])
}
if (decisionsRes.ok) {
const data = await decisionsRes.json()
setDecisions(data.decisions || [])
}
} catch (err) {
if (!silent) addToast(`Failed to load middleware status: ${err.message}`, 'error')
} finally {
if (!silent) setLoading(false)
}
}, [addToast])
useEffect(() => { fetchAll() }, [fetchAll])View on GitHub (pinned to 44413a9d06)
Solutions
- curl -i http://<host>:<port>/api/middleware/status directly and check the status code and body
- If 401/403, re-authenticate or refresh the token; the silent poll suppresses auth failures so check the network tab
- If 404, verify the server build includes the middleware routes and that apiUrl() prefix matches the served path
- If 5xx, inspect the LocalAI server logs for the middleware status handler panic
Example fix
// before
if (!statusRes.ok) throw new Error(`status: HTTP ${statusRes.status}`)
// after: include response body detail when available
if (!statusRes.ok) {
let detail = ''
try { detail = (await statusRes.json())?.error || '' } catch { /* non-JSON body */ }
throw new Error(`status: HTTP ${statusRes.status}${detail ? `: ${detail}` : ''}`)
} Defensive patterns
Strategy: retry
Validate before calling
// Before mounting, confirm the route exists so the initial load fails fast and clearly
async function middlewareStatusReachable(apiBase) {
try {
const res = await fetch(`${apiBase}/api/middleware/status`)
return res.ok
} catch { return false }
} Try / catch
// Distinguish transient from permanent: silent polls retry, user-triggered loads toast
try {
await fetchAll(false)
} catch (err) {
if (/HTTP 5\d\d/.test(err.message)) setTimeout(() => fetchAll(true), 5000) // server hiccup: back off and retry silently
else addToast(`Middleware unavailable: ${err.message}`, 'error') // 401/404: needs user action
} Prevention
- Keep the /api prefix consistent between apiUrl() and the reverse proxy
- Run auth token refresh before long-lived pages that poll
- Treat 5xx on background polls as transient with backoff, 401/403 as session expiry requiring re-auth
When it happens
Trigger: Calling GET /api/middleware/status and receiving 404 (route/middleware not built or disabled), 401/403 (auth enabled and token expired between page load and fetch), 500 (middleware subsystem crash), or the API_PREFIX/proxy misrouting apiUrl() to a path the server does not serve.
Common situations: Reverse proxy stripping or rewriting the /api prefix; LocalAI started with middleware features compiled/disabled; expired session on a long-open tab where the silent poll starts failing after the initial load succeeded; gateway timeout when middleware status collection blocks.
Related errors
- No job ID returned from server
- HTTP ${response.status}
- Export failed
- HTTP ${res.status}
- HTTP ${response.status}
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/a5b2787968bfddee.
Report an issue: GitHub.