Vite-proxy node v17+ encounters ECONNREFUSED error
P粉683665106
P粉683665106 2023-11-07 20:00:40
0
1
1194

I am using Node v18.12.1 and vite v3.0.4. Here is my proxy code to connect to the Node.js REST API from the Vue.js vite development server:

proxy: {
  "/api": {
    target: "http://localhost:3000",
    changeOrigin: true,
  }
}

After updating my node version from v16, I now receive this error from vite-proxy:

[vite] http proxy error:
Error: connect ECONNREFUSED ::1:3000
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1300:16) (x3)

I heard that starting from sine v17, Node supports ipv6 as localhost. How can I solve this problem?

P粉683665106
P粉683665106

reply all(1)
P粉807397973

You can run the service you are trying to connect to on ::1 or configure the proxy target to use an IPv4 address (http://127.0.0.1:3000code> ).

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template