Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devServerProxy not working (ECONNREFUSED) #518

Closed
0101 opened this issue Jun 2, 2022 · 1 comment
Closed

devServerProxy not working (ECONNREFUSED) #518

0101 opened this issue Jun 2, 2022 · 1 comment

Comments

@0101
Copy link

0101 commented Jun 2, 2022

After creating a new project from the template (v3.1.1) and starting it up, communication between client and server doesn't work. In the console I see:

client: [HPM] Error occurred while trying to proxy request /api/ITodosApi/getTodos from 0.0.0.0:8080 to http://localhost:8085 (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

I don't know if this is caused by some mis-configuration of my system (MacOs Big Sur) but it could probably affect others as well.

After a while I managed to fix it by changing the devServerProxy to target 0.0.0.0 instead of localhost:

devServerProxy: {
  // redirect requests that start with /api/ to the server on port 8085
  '/api/**': {
      target: 'http://0.0.0.0:' + (process.env.SERVER_PROXY_PORT || "8085"),
         changeOrigin: true
     },
  // redirect websocket requests that start with /socket/ to the server on the port 8085
  '/socket/**': {
      target: 'http://0.0.0.0:' + (process.env.SERVER_PROXY_PORT || "8085"),
      ws: true
     }
 }

Not sure if this change could have some adverse effects on someone else's system. So hopefully someone who understands this better than me can pitch in :)

@olivercoad
Copy link
Contributor

If you're using node version 17 or higher, see #490.

@theprash theprash closed this as completed Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants