You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_All_`http-proxy`[options](https://github.com/nodejitsu/node-http-proxy#options) can be used, along with some extra `http-proxy-middleware`[options](#options).
Check out [interception recipes](https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/response-interceptor.md#readme) for more examples.
575
576
577
+
## Node.js 17+: ECONNREFUSED issue with IPv6 and localhost ([#705](https://github.com/chimurai/http-proxy-middleware/issues/705))
578
+
579
+
Node.js 17+ no longer prefers IPv4 over IPv6 for DNS lookups.
580
+
E.g. It's **not** guaranteed that `localhost` will be resolved to `127.0.0.1` – it might just as well be `::1` (or some other IP address).
581
+
582
+
If your target server only accepts IPv4 connections, trying to proxy to `localhost` will fail if resolved to `::1` (IPv6).
583
+
584
+
Ways to solve it:
585
+
586
+
- Change `target: "http://localhost"` to `target: "http://127.0.0.1"` (IPv4).
587
+
- Change the target server to (also) accept IPv6 connections.
588
+
- Add this flag when running `node`: `node index.js --dns-result-order=ipv4first`. (Not recommended.)
589
+
590
+
> Note: There’s a thing called [Happy Eyeballs](https://en.wikipedia.org/wiki/Happy_Eyeballs) which means connecting to both IPv4 and IPv6 in parallel, which Node.js doesn’t have, but explains why for example `curl` can connect.
591
+
576
592
## Debugging
577
593
578
594
Configure the `DEBUG` environment variable enable debug logging.
0 commit comments