NullInjectorError: No provider for HttpClient! Angular Origin: On your device Last updated 15 Oct 2026

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.

Exact message you may see NullInjectorError: No provider for HttpClient!No provider for HttpClientR3InjectorError HttpClient
Seen on: Angular TypeScript

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 in app.config.ts / bootstrap providers
  • HttpClientModule not 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

  1. Add provideHttpClient() to the application config
  2. NgModule: import HttpClientModule once in AppModule
  3. In tests add provideHttpClient() and provideHttpClientTesting()

Detailed fix by platform

Angular

  1. export const appConfig: ApplicationConfig = { providers: [provideRouter(routes), provideHttpClient(withInterceptors([authInterceptor]))] };
  2. Tests: TestBed.configureTestingModule({ providers: [provideHttpClient(), provideHttpClientTesting()] })

Code examples

app.config.ts

typescript
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

  1. App type — Standalone or NgModule?
  2. Tests — TestBed has HTTP providers?
  3. 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:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Http failure during parsing — Angular: Http failure during parsing for http://…: SyntaxError: Unexpected token '<' (response is not JSON) (Angular)Http failure during p…Http failure response for (unknown url): 0 Unknown Error — Angular: HttpErrorResponse — Http failure response for (unknown url): 0 Unknown Error (status 0) (Angular)Http failure response…Http failure response: 404 Not Found — Angular: Http failure response for http://…/api/x: 404 Not Found (HttpErrorResponse) (Angular)Http failure response…NG0200 — Angular: NG0200: Circular dependency in DI detected for X (Angular)NG0200NG0201 — Angular: NG0201: No provider for X found in NodeInjector (Angular)NG0201NG0203 — Angular: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer or a function used with runInInjectionContext (Angular)NG0203NullInjectorError — Angular: NullInjectorError: No provider for X! (Angular)NullInjectorErrorNullInjectorError: No provider for ActivatedRoute! — Angular: NullInjectorError: No provider for ActivatedRoute! (also Router) — usually a unit test (Angular)NullInjectorError: No…NullInjec…

Explore the map of this error Full error map →

🧠 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.