[HPM] Proxy error: ECONNREFUSED
Hi, I am serving a web application with gulp.js in port 3000, and a php backend application served in port 8000.
I am trying to use http-proxy-middleware in my gulp serve task in order to defer any calls from localhost:3000/api to my api endpoint at: localhost:8000/api. I have used it as follows:
proxyMiddleware('/api', { target: 'http://localhost:8000' });
For instance if I try to POST to api/authenticate, nodejs gives me in the console:
[HPM] Proxy error: ECONNREFUSED localhost:8000/api/authenticate
So what I can see here is that it's actually trying to proxy it, but returns this unexpected error. Inspecting the network response I get:
Error occured while trying to proxy to: localhost:3000/api/authenticate
I don't know if this problem is related to myself using this module in an incorrect manner, any help would be very appreciated. Thanks in advance.
It was a problem with the artisan server, had to run it this way:
php artisan serve --host 0.0.0.0
The following also worked for me:
php artisan serve --host 127.0.0.1