-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Localhost no longer works for devServer proxy. #4828
Comments
Can you create reproducible example? |
I can confirm this as well. The issue with me was that I was in the process of upgrading my nodejs v14.20 -> nodejs 18.14.2 This was the version of webpack dev server I was using
using Then doing The only thing that seemed to fix it was I'm not familiar what could be the reason for this behavior however I hope this helped in some way. I appreciate this post, thanks for giving me a workaround solution in the meanwhile |
@IsaaX Can you share a minimal reproduction repo? |
Sounds like this nodejs 17 change (nodejs/node#39793):
TL;DR
Most likely related to upgrading node v16 or lower to node v17 or higher. |
That Node17 change causes a lot of problems around the place, sadly. This causes issues because not all environments will resolve I think the best course of action is to update webpack-dev-server so that it does a Or at least - do this specifically for the Simple example code that could be used: const dns = require('dns');
const addresses = /** @type {import('dns').LookupAddress[]} */ (await new Promise((resolve, reject) =>
dns.lookup('localhost', { all: true }, (error, addresses) => {
if (error) {
reject(error);
} else {
resolve(addresses);
}
}),
));
for (const {address} of addresses) {
// bind to address
} It looks like this isn't a super simple problem to solve in the codebase though because it would involve spinning up two separate servers - because one |
We can't fix it here, sorry, close in favor https://github.com/chimurai/http-proxy-middleware#nodejs-17-econnrefused-issue-with-ipv6-and-localhost-705 |
Bug report
Dev Server proxy targets no longer accept localhost as a valid option. After upgrading to v4, I have had to switch from
localhost
to127.0.0.1
which is the same thing so it makes no sense.There was nothing about this included in the v4 migration post which leads me to believe this is a bug.
Actual Behaviour
When making HTTP requests (through axios) to my server backend, I get proxy errors. These are the exact same errors I get when the server isn't even running. Upon switching the target to
127.0.0.1
, it works.Expected Behaviour
I honestly don't know how to explain the expected behaviour as I'm not entirely sure why it's not working to begin with. HTTP requests should connect to the server and only throw this error if the server cannot be found.
localhost
and127.0.0.1
are synonymous so working on one and not the other makes zero sense.How Do We Reproduce?
I am using webpack-dev-server through vue-cli, but upon asking for help from them, I was informed that they pass these settings along to webpack and it's not handled by Vue. That said, here are my settings:
I then have an Axios instance:
All HTTP requests go through that.
Please paste the results of
npx webpack-cli info
here, and mention other relevant informationThe text was updated successfully, but these errors were encountered: