diff --git a/lib/health-indicator/http/http.health.ts b/lib/health-indicator/http/http.health.ts index 2411a7283..8ac22b971 100644 --- a/lib/health-indicator/http/http.health.ts +++ b/lib/health-indicator/http/http.health.ts @@ -146,9 +146,13 @@ export class HttpHealthIndicator extends HealthIndicator { httpService.request({ url: url.toString(), ...options }), ); } catch (error) { - if (isAxiosError(error) && error.response) { - response = error.response; - axiosError = error; + if (isAxiosError(error)) { + if (error.response) { + response = error.response; + axiosError = error; + } else { + throw this.generateHttpError(key, error); + } } else { throw error; }