janhq/jan · error · Error
Cannot connect to ${provider.provider} at ${provider.base_ur
Error message
Cannot connect to ${provider.provider} at ${provider.base_url}. Please check that the service is running and accessible. What it means
Thrown when getModels catches an error whose message contains the substring 'fetch' - the signature of a network-level failure from fetchTauri (TypeError: Failed to fetch, DNS failure, connection refused, TLS error, CORS rejection). It reformulates the low-level network error into an actionable message naming the provider and base_url.
Source
Thrown at web-app/src/services/providers/tauri.ts:272
const structuredErrorPrefixes = [
'Authentication failed',
'Access forbidden',
'Models endpoint not found',
'Failed to fetch models from',
]
if (
error instanceof Error &&
structuredErrorPrefixes.some((prefix) =>
(error as Error).message.startsWith(prefix)
)
) {
throw new Error(error.message)
}
// Provide helpful error message for any connection errors
if (error instanceof Error && error.message.includes('fetch')) {
throw new Error(
`Cannot connect to ${provider.provider} at ${provider.base_url}. Please check that the service is running and accessible.`
)
}
// Generic fallback
throw new Error(
`Unexpected error while fetching models from ${provider.provider}: ${error instanceof Error ? error.message : 'Unknown error'}`
)
}
}
async updateSettings(
providerName: string,
settings: ProviderSetting[]
): Promise<void> {
try {
// API keys are persisted to the OS keyring only (via
// register_provider_config), never to the extension's settings.json.View on GitHub (pinned to fad3f12a14)
Solutions
- Confirm the service is running: curl -i ${base_url}/models from a terminal.
- Verify base_url exactly - scheme (http/https), host, port, and no trailing slash / path mismatches.
- For localhost providers, confirm the Origin header logic applies; it only triggers for hosts containing 'localhost:' or '127.0.0.1:'.
- For self-signed certs, trust the cert or use http locally; check the provider's CORS configuration.
Example fix
// before: localhost provider not started -> 'Cannot connect to llama.cpp at http://127.0.0.1:8080...'
// after: validate reachability when saving provider settings
async function pingProvider(base_url: string, key?: string): Promise<boolean> {
const headers: Record<string,string> = {}
if (key) { headers['x-api-key'] = key; headers['Authorization'] = `Bearer ${key}` }
try { return (await fetch(`${base_url}/models`, { headers })).ok } catch { return false }
} Defensive patterns
Strategy: retry
Validate before calling
async function canReach(base_url: string): Promise<boolean> {
try {
await fetch(`${base_url}/models`, { method: 'GET', mode: 'no-cors' })
return true
} catch { return false }
} Type guard
function isConnectionError(e: unknown): boolean {
return e instanceof Error && /fetch|network|ECONNREFUSED|ENOTFOUND|certificate|CORS/i.test(e.message)
} Try / catch
try {
await provider.getModels(p)
} catch (e) {
if (isConnectionError(e)) {
showRetryableError(`Cannot reach ${p.base_url}`, { retry: () => provider.getModels(p) })
} else throw e
} Prevention
- Run a connectivity test when saving provider settings.
- Offer a retry button for connection errors.
- Surface base_url prominently so users can spot typos.
When it happens
Trigger: fetchTauri rejects with a TypeError such as 'Failed to fetch' - provider host unreachable, wrong base_url scheme/host/port, CORS preflight failure, TLS certificate error, or a localhost service that is not running.
Common situations: User configured a local provider (llama.cpp / Ollama) but it is not running; base_url typo; HTTPS endpoint with a self-signed cert; CORS blocking the request from the Tauri webview; the localhost Origin-header injection (tauri://localhost) did not apply because the host string did not match 'localhost:' or '127.0.0.1:'.
Related errors
- Failed to fetch models from ${provider.provider}: ${result.s
- Models endpoint not found for ${provider.provider}. Check th
- Failed to fetch models from ${provider.provider}: ${response
- Checksum mismatch for ${name}; the download was corrupt or t
- Failed to fetch supported backends: ${error instanceof Error
AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12).
Data as JSON: /api/errors/b2e13f6b18aae382.
Report an issue: GitHub.