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.
[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 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 servestarted 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
- Start with
ng serve --proxy-config proxy.conf.json - Make sure the API is running on the target port
- Use relative URLs (
/api/users) in the app
Detailed fix by platform
Angular CLI
- In angular.json:
"serve": { "options": { "proxyConfig": "proxy.conf.json" } } - Debug with
"logLevel": "debug"in the proxy entry
Code examples
Path rewrite
{
"/api": {
"target": "http://localhost:3000",
"secure": false,
"changeOrigin": true,
"pathRewrite": { "^/api": "" },
"logLevel": "debug"
}
}How to diagnose
- Enabled — Is proxyConfig set and the server restarted?
- Match — Does the request start with the prefix?
- 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:
Similar errors
- Cannot find control with name Angular: Error: Cannot find control with name: 'email' (reactive forms)
- 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
- Http failure response for (unknown url): 0 Unknown Error Angular: HttpErrorResponse — Http failure response for (unknown url): 0 Unknown Error (status 0)
Most viewed in Angular
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