janhq/jan · error
Cannot connect to at . Please check that the service is…
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 the underlying fetch itself failed (the error message contains 'fetch'), i.e. the request never got an HTTP response. The app translates low-level network failures into a friendly message saying the provider service at base_url could not be reached.
Solutions
- Start/restart the local inference server and confirm it listens on the port in base_url.
- Test connectivity: `curl <base_url>/models` from the same machine.
- Correct the base_url scheme/host/port (e.g. http://localhost:8080 vs https).
- If remote, check DNS/firewall/VPN and that the provider is up.
Example fix
// before base_url: 'http://localhost:1337' // server actually on 8080 // after base_url: 'http://localhost:8080'
Defensive patterns
Strategy: try-catch
Validate before calling
// Cheap reachability probe before the real call
async function isReachable(base_url: string): Promise<boolean> {
try { await fetch(base_url.replace(/\/$/, '') + '/models', { method: 'HEAD' }); return true } catch { return false }
} Type guard
function isLocalUrl(url: string): boolean {
return url.includes('localhost:') || url.includes('127.0.0.1:')
} Try / catch
try {
await fetchModelsFromProvider(provider)
} catch (e) {
if (e instanceof Error && e.message.startsWith('Cannot connect to')) {
guideStartLocalServer(provider.base_url) // show start-server instructions
}
} Prevention
- Check the local server is running before listing models.
- Validate scheme/host/port of base_url during configuration.
- Surface a health-check indicator for local providers in the UI.
When it happens
Trigger: fetchTauri throws a TypeError/fetch error: server not running, wrong port, DNS failure, TLS error, or the webview blocks the request (CORS/mixed content).
Common situations: Local llama.cpp/Ollama server not started or on a different port; base_url has a typo (http vs https, wrong host); remote provider unreachable offline; self-signed certificate rejected.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- ( )
- Failed to fetch model catalog
- Models endpoint not found for
- All endpoints failed
- API request failed with status
AI-assisted analysis of janhq/jan@7205d770c1 (2026-09-17).
Data as JSON: /api/errors/b2e13f6b18aae382.
Report an issue: GitHub.
Appendix: 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 7205d770c1)