proxy.conf.json not working Angular Origin: On your device Last updated 15 Oct 2026

Angular CLI: [HPM] Error occurred while proxying request localhost:4200 to http://localhost:3000 [ECONNREFUSED]

The ng serve dev proxy cannot forward your API call — it was not enabled, the path does not match, or the target server is down.

Exact message you may see [HPM] Error occurred while proxying requestproxy.conf.json not workingError occurred while trying to proxy request[HPM] Error occurred while proxying request localhost:4200 to http://localhost:3000ECONNREFUSED ng serve proxy
Seen on: Angular Angular CLI

Meaning

Add --proxy-config proxy.conf.json (or set proxyConfig in angular.json) and restart ng serve; the file is read only at start. Paths must match the request URL prefix, and the target must be reachable. HPM errors like ECONNREFUSED mean the back end is not listening; 404 means the path rewrite is wrong.

Common causes

  • ng serve started without --proxy-config / proxyConfig
  • Dev server not restarted after editing the file
  • Request path does not start with the configured prefix (/api)
  • Back-end target not running or wrong port (ECONNREFUSED)
  • HTTPS target with self-signed certificate needs secure: false

⚡ Quick fix

  1. Start with ng serve --proxy-config proxy.conf.json
  2. Make sure the API is running on the target port
  3. Use relative URLs (/api/users) in the app

Detailed fix by platform

Angular CLI

  1. In angular.json: "serve": { "options": { "proxyConfig": "proxy.conf.json" } }
  2. Debug with "logLevel": "debug" in the proxy entry

Code examples

Path rewrite

json
{
  "/api": {
    "target": "http://localhost:3000",
    "secure": false,
    "changeOrigin": true,
    "pathRewrite": { "^/api": "" },
    "logLevel": "debug"
  }
}

How to diagnose

  1. Enabled — Is proxyConfig set and the server restarted?
  2. Match — Does the request start with the prefix?
  3. Target — Is the API listening?

🔧 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):

Cannot find control with name — Angular: Error: Cannot find control with name: 'email' (reactive forms) (Angular)Cannot find control w…exceeded maximum budget — Angular build: Error: bundle initial exceeded maximum budget. Budget 1.00 MB was not met by 120.00 kB with a total of 1.12 MB (Angular)exceeded maximum budg…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…listen EACCES — Error: listen EACCES: permission denied 0.0.0.0:80 (Node.js)listen EACCESPort 4200 is already in use — Angular CLI: Port 4200 is already in use. Use '--port' to specify a different port (Angular)Port 4200 is already …Schema validation failed with the following errors — Angular CLI: Schema validation failed with the following errors: Data path "" must NOT have additional properties(xyz) (Angular)Schema validation fai…proxy.con…

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.