# Angular: Http failure response for http://…/api/x: 404 Not Found (HttpErrorResponse)

**Code:** `Http failure response: 404 Not Found` · **Category:** Angular · **Seen on:** Angular, TypeScript

The API answered 404 — the URL is wrong (base URL, path or id), or the proxy/rewrite does not forward the request.

## Meaning

`HttpClient` throws `HttpErrorResponse` for 4xx/5xx. A 404 in Angular apps usually comes from a missing `/api` prefix, a wrong environment base URL, a dev proxy that does not rewrite the path, or hosting that serves `index.html` for unknown API paths. The `error.url` shows exactly which URL was called.

## Common causes

- Wrong base URL or missing prefix (`/api`) in the service
- Environment file points at the wrong host or stage
- Dev proxy not forwarding or not rewriting the path
- Resource really does not exist (bad id)
- Route removed or renamed on the back end

## Quick fix

1. Log `error.url` and compare it with the API docs
2. Check `environment.ts` and the proxy config
3. Test the same URL with curl or Postman

## Detailed fix by platform

### Angular

1. `this.http.get(`${environment.apiUrl}/users/${id}`).pipe(catchError(err => { console.error(err.url, err.status); return EMPTY; }))`
2. Check `fileReplacements` in angular.json for production builds

### Linux

1. `curl -i https://api.example.com/users/7`

## How to diagnose

1. **URL** — What is error.url?
2. **Env** — Correct environment file used for this build?
3. **API** — Does the endpoint exist?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/http-failure-response-404-not-found)
