immich-app/immich · error · Error

Machine learning request '${JSON.stringify(config)}' failed

Error message

Machine learning request '${JSON.stringify(config)}' failed for all URLs

What it means

MachineLearningRepository.predict iterates all configured ML server URLs (healthy ones first, then unhealthy). Each failure — non-2xx HTTP status or a network/throw — is logged as a warning and the URL is marked unhealthy. If no URL succeeds, it throws Error('Machine learning request <config-json> failed for all URLs'). This is the catch-all when smart-search/face-detection/clip cannot reach any ML backend.

Source

Thrown at server/src/repositories/machine-learning.repository.ts:191

        const response = await fetch(new URL('predict', url), { method: 'POST', body: formData });
        if (response.ok) {
          this.setHealthy(url, true);
          return response.json();
        }

        this.logger.warn(
          `Machine learning request to "${url}" failed with status ${response.status}: ${response.statusText}`,
        );
      } catch (error: Error | unknown) {
        this.logger.warn(
          `Machine learning request to "${url}" failed: ${error instanceof Error ? error.message : error}`,
        );
      }

      this.setHealthy(url, false);
    }

    throw new Error(`Machine learning request '${JSON.stringify(config)}' failed for all URLs`);
  }

  async detectFaces(imagePath: string, { modelName, minScore }: FaceDetectionOptions) {
    const request = {
      [ModelTask.FACIAL_RECOGNITION]: {
        [ModelType.DETECTION]: { modelName, options: { minScore } },
        [ModelType.RECOGNITION]: { modelName },
      },
    };
    const response = await this.predict<FacialRecognitionResponse>({ imagePath }, request);
    return {
      imageHeight: response.imageHeight,
      imageWidth: response.imageWidth,
      faces: response[ModelTask.FACIAL_RECOGNITION],
    };
  }

  async encodeImage(imagePath: string, { modelName }: CLIPConfig) {

View on GitHub (pinned to 199723261c)

Solutions

  1. Check the ML server health/logs (/predict endpoint) and restart it if down.
  2. Verify IMMICH_MACHINE_LEARNING_URL points to the correct reachable address from the server process.
  3. Confirm required model files are present and the ML image matches the server version.
  4. If running multiple ML URLs, ensure at least one is healthy; check the availability-check status logged by Immich.
Defensive patterns

Strategy: retry

Validate before calling

// health-check ML URLs before sending real work
for (const url of ML_URLS) {
  const ok = await fetch(new URL('/ping', url)).then((r) => r.ok).catch(() => false);
  if (!ok) console.warn(`ML server unhealthy: ${url}`);
}

Try / catch

try {
  await ml.predict(payload, config);
} catch (e) {
  if (/failed for all URLs/.test((e as Error).message)) {
    // alert ops, queue job for retry, degrade feature gracefully
  } else throw e;
}

Prevention

When it happens

Trigger: All configured IMMICH_MACHINE_LEARNING_URL servers are down, returning errors, or unreachable when an ML prediction (detectFaces / encodeImage / encodeText) is attempted.

Common situations: ML container not started or crashing; wrong URL/port in env; network policy/firewall blocking the API; ML model files missing causing the server to 500; resource exhaustion (OOM) on the ML server.

Related errors


AI-assisted analysis of immich-app/immich@199723261c (2026-08-12). Data as JSON: /api/errors/d6a876ffe6612af9. Report an issue: GitHub.