Reputation: 41
first time asking questions here so please let me know if I am missing any of the best practices.
I am working on an Angular 4 application that uses proxy to simplify the communication between front and back end of the application.
The proxy setting is the following:
{
"/api": {
"target": "http://localhost:9000",
"secure": false
},
"/auth": {
"target": "http://localhost:9000",
"secure": false
}
}
In my main computer, when I run the part of the application that would call the proxy I get the following error.
[HPM] Error occurred while trying to proxy request /auth/google from localhost:4200 to http://localhost:9000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
The chrome console displays a 504 error.
The command I used to run all the servers
concurrently \"mongod\" \"ng serve -pc proxy.conf.json --open\" \"tsc -w -p server\" \"nodemon dist/server/app.js\"
When the application is building, I can see that the proxy has been set up by the program, but the same error still happens.
[1] [HPM] Proxy created: /api/** -> http://localhost:9000
[1] [HPM] Subscribed to http-proxy events: [ 'error', 'close' ]
[1] [HPM] Proxy created: /auth/** -> http://localhost:9000
[1] [HPM] Subscribed to http-proxy events: [ 'error', 'close' ]
However, when I try to run it on another computer that I have (exact same code, node setting, network environment etc.), the proxy is working.
I tried to replicate the error by making all application related setting identical between two computers (node version, npm version, clean installed all node packages and even pulled the application clean from github on both computers), but the error still persists on one but not the other.
Can someone make some suggestions on where should I look or what I should do next to identify the root cause of this problem? Thanks!
Things I've done so far:
nodejs version: 6.10.3
npm version: 5.6.0
Upvotes: 3
Views: 2337
Reputation: 41
Per suggestion of a friend, I ended up running
sudo lsof -i :9000
to see if there is anything in 9000 that could potentially interfere with the port. There ended up being few php listeners in the same port that is running while the node server is running - and those php listeners are the culprit of the error.
So I ran the following command to kill the listeners and the problem because resolved.
kill -kill `lsof -t -i tcp:9000`
Have no idea why node didn't spew out the "port in use" error but oh well its resolved now.
Rationale of the story: check your ports to make sure its not occupied.
Upvotes: 1