Angular: NullInjectorError: No provider for HttpClient! — provideHttpClient() missing
A service or component injects HttpClient, but HTTP support was never added to the app's providers.
NullInjectorError: No provider for HttpClient!No provider for HttpClientR3InjectorError HttpClient Meaning
HttpClient is not provided by default. Standalone apps call provideHttpClient() in bootstrapApplication / app.config.ts; NgModule apps import HttpClientModule. Tests also need provideHttpClient() plus provideHttpClientTesting().
Common causes
provideHttpClient()missing inapp.config.ts/ bootstrap providersHttpClientModulenot imported in the root NgModule- Test without
HttpClientTestingModule/provideHttpClientTesting() - Provider added in a lazy module but injected elsewhere
- Library requiring HttpClient used before it is provided
⚡ Quick fix
- Add
provideHttpClient()to the application config - NgModule: import
HttpClientModuleonce inAppModule - In tests add
provideHttpClient()andprovideHttpClientTesting()
Detailed fix by platform
Angular
export const appConfig: ApplicationConfig = { providers: [provideRouter(routes), provideHttpClient(withInterceptors([authInterceptor]))] };- Tests:
TestBed.configureTestingModule({ providers: [provideHttpClient(), provideHttpClientTesting()] })
Code examples
app.config.ts
import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideHttpClient, withFetch } from '@angular/common/http';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [provideRouter(routes), provideHttpClient(withFetch())],
};How to diagnose
- App type — Standalone or NgModule?
- Tests — TestBed has HTTP providers?
- Scope — Provided where the service lives?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Http failure during parsing Angular: Http failure during parsing for http://…: SyntaxError: Unexpected token '<' (response is not JSON)
- Http failure response for (unknown url): 0 Unknown Error Angular: HttpErrorResponse — Http failure response for (unknown url): 0 Unknown Error (status 0)
- Http failure response: 404 Not Found Angular: Http failure response for http://…/api/x: 404 Not Found (HttpErrorResponse)
Most viewed in Angular
- NG0100 Angular: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked
- NG8002 Angular: NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'
- Cannot GET /route on refresh Angular (production): Cannot GET /dashboard — 404 when refreshing or opening a deep link
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026