ERR_INVALID_REDIRECT when running http-server
matpl opened this issue Β· 141 comments
Do you want to request a feature or report a bug?
If the issue is a bug report, please provide the steps to reproduce it. Please include the actual command causing the issue if applicable.
npm i -g http-server
http-server
Then open chrome at 127.0.0.1:8080
What did you expect to happen?
Open an empty page
What actually happened? Please include the actual error trace and / or stack trace if applicable.
ERR_INVALID_REDIRECT
If the issue is a feature request, what is the motivation / use case for it?
Tell us about your environment
- http-server version:
Tried 0.11 and also the master branch from the github repo - Platform:
win10
I feel it may be related to the ecstatic issue earlier today... Could it be possible that the updated version of ecstatic (3.3.2) isn't compatible with http-server?
What is in the directory you're serving? I'm not getting the same on my Mac
I'm serving the current directory. I tried with an index.html with an empty body, but I still get ERR_INVALID_REDIRECT. I'm at work so it could possibly be a proxy issue or something. I can try again at home later today to see if I get the same behavior.
I have the same issue. I'm running http-server on Windows 10, and getting the same error. I updated http-server and ecstatic, but it didn't work. In my case I only have a single html page (index.html).
Just an idea, but do any of you see the same thing if you use npx http-server-legacy
instead of http-server
?
I have the same issue with npx http-server-legacy. And I use http-server on a weekly basis I'd say, and I only had this error from a fresh install for http-server. So it was working fine with the latest version in the last weeks, and it stopped working after a clean install today (with the same version). That's why I suspect a dependency issue.
i have the same issue, both http-server and http-server-legacy,
no solution so far
I think the issue is somehow related to directories.
When I enter http://localhost:8080
, I get the same error, however requesting http://localhost:8080/index.html
directly works.
A weird thing happens when I request a directory under the root. When I go to
http://localhost:8080/folder
it redirects me to this address:
http://localhost:8080/folder///////////////////
and produces this error:
This page isnβt working
localhost redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
Just an idea, but do any of you see the same thing if you use
npx http-server-legacy
instead ofhttp-server
?
I have tried npx http-server-legacy
now, still giving the error.
I'm having exactly the same error as @captainturtle on windows only. Seems to be working fine on OSX.
Possibly related to ecstatic issue as mentioned:
It's definitely ecstatic. I downgraded to 3.0.0 and the issue disappears.
@bspammer I did the same and solved it too.
Ahhh this is so annoying. Because of this ecstatic thing, I waited 2 days before my CI gets back up again. Now my dev server is broken.
Can confirm this bug still exists.
Confirmed the issue is due to http-server being incompatible ecstatic 3.3.2. Updating http-server's package.json to require ecstatic 3.3.1 fixes http-server for me.
Getting the same issue.
Same here, exactly as @captainturtle described it.
This seems to be caused by jfhbrook/node-ecstatic#260, which is unlikely to ever be fixed. Is anyone seeing this on a non-Windows machine?
This resolv my problem
PS C:\myapp> node --version
v12.2.0
PS C:\myapp> npm --version
6.9.0
PS C:\myapp> npm install -g http-server@0.9.0
Just confirmed - same problem and tuxpedro's solution worked for me on Windows (version 0.9.0 of http-server which uses a much earlier ecstatic it looks like). I tried forcing ecstatic to 3.3.1 like mikeycooper, but that did not work for me.
Same issue. My http-server was using ecstatic 3.0.0 and it was not working. @tuxpedro solution worked
I've seen this happen to a dozen or so of my web students this week, and it only seems to be on Windows.
Follow-up from one of my students, who says that using http://localhost:8080
causes the bug, but explicitly using http://localhost:8080/index.html
works.
Downgrading to http-server 0.9.0 fixed it for me under Windows
Same issue on Windows.
Downgrading to 0.9.0 or explicitly using *.html worked
Same issue on Windows 10 Insider Preview 18890.
I fixed it by adding ecstatic 3.0.0 entry in package.json and then npm install.
Is there any solutions, I got the same issues,
This way can works ~~~
@elainema Of course manually appending "/index.html" will work but this is not the point of this issue. Read the "Magic Files" section documented in README.md: index.html will be served as the default file to any directory requests.
Same issue here.
node v8.11.3
npm v6.9.0
http-server v0.11.1
@sjb250 It's because no redirection took place as you specified the file name. This issue is all about using /. No one on earth types /index.html when he or she visits a website, e.g. www.apple.com/index.html.
I had the same issue, only wanted to run a server locally for js/html files, I downloaded live-server (npm install live-server -g) and the issue was fixed
@najibsa3d Live-server works, thanks!
This is caused by ecstatic@3.2.2
, works normally with ecstatic@3.2.1
.
Installing ecstatic@3.2.1
fixes this issue, but 3.2.2 contains a security fix:
https://www.npmjs.com/advisories/830
so downgrading this dependency will work, but I wouldn't advise it unless you're using the server for development purposes only (which is probably the main use case of this package anyway)
@SkaceKamen Thank you for the information. May I know which server package should I use for production? Could you recommend one? Thanks a lot.
using " http://localhost:8080/index.html " solved " ERR_INVALID_REDIRECT " problem
if it is a SPA such as working with react router, is still doesn't work in this way by adding index.html ...
I used ( npm install http-server@0.9.0 ) ... that solved the problem for me .
Have Any one more professional solution ?
http-server@0.11.1
ecstatic@3.3.2
same issue exists (ERR_INVALID_REDIRECT)
It a problem with regard to ecstatic.
I fixed it in jfhbrook/node-ecstatic#261 .
I used ( npm install http-server@0.9.0 ) ... that solved the problem for me .
Have Any one more professional solution ?
no error with 0.9.0
It a problem with regard to ecstatic.
I fixed it in jfhbrook/node-ecstatic#261 .
@Xmader I have a feeling that your pull request will never be accepted. See this: jfhbrook/node-ecstatic#259
Here's the key quote from the very long text: "I will not accept patches or push updates to ecstatic going forward. This includes security updates."
Since you know what the issue is do you think you could do a workaround directly to the http-server
package? If not then I think the only way to fix this is to set the ecstatic dependency in the package.json
to an exact version that still works - which is 3.2.1 according to earlier comments.
Here's the key quote from the very long text: "I will not accept patches or push updates to ecstatic going forward. This includes security updates."
That's a pity.
Or we can create a fork and continue maintaining it.
Confirmed the issue is due to http-server being incompatible ecstatic 3.3.2. Updating http-server's package.json to require ecstatic 3.3.1 fixes http-server for me.
Can someone tell me how to down grade the ecstatic version for the already installed http-server? I'm new to npm
@priyal85, just edit package.json and add an entry with a older version of ecstatic. I'm using live-server now coz it just works.
@priyal85, just edit package.json and add an entry with a older version of ecstatic. I'm using live-server now coz it just works.
@blackr1234 Thanks! I did this and still get the same error. After changing the package.jsaon do I have to run any command to update it
@priyal85, I think I run a "npm install" under the project folder after updating package.json. It's the command you should always run after updating package.json. IIRC, I tried ecstatic v3.0.0 and it worked as mentioned by some other developers above.
It's definitely ecstatic. I downgraded to 3.0.0 and the issue disappears.
yes, I manually changed the http-server reference to be 3.0.0 and restarted.
you can also change the estatic dependency to just * and it will grab the latest version. That also seems to be working for me.
I had the same issue, only wanted to run a server locally for js/html files, I downloaded live-server (npm install live-server -g) and the issue was fixed
i run the following command
npm install live-server -g
cd dist/appname
http-server -o
Still not working. Error "This page isnβt working 127.0.0.1 sent an invalid response.
ERR_INVALID_REDIRECT"
Hm, reading through this issue it seems there's no fix yet, right? Are there any plans to move away from ecstatic now that it's a known dead package?
We need windows support & we use http-server
in all of our SDK test suites to server a simple TodoMVC app. I'd also rather not see this security warning on each of our SDKs. You can see it failing:
- percy/percy-puppeteer#106
- percy/percy-cypress#117
- percy/example-percy-protractor#36
- percy/percy-protractor#60
- percy/percy-nightwatch#64
... etc
Happy to provide help how ever I can. π
Here's the key quote from the very long text: "I will not accept patches or push updates to ecstatic going forward. This includes security updates."
That's a pity.
Or we can create a fork and continue maintaining it.
https://github.com/node-extatic/extatic
npm i extatic
Same error here. Look, when you got a dependency that does not serve you anymore, you should put it in a bin and look for another alternative.. What ecstatic did for http-server that worked good in the past and doesn't work anymore? We can do it ourselves. Even if we need to rewrite a good lib to do it. The source of the error is that the author won't mantain the module anymore, he had some conflict with npm because of a security issue. See here: jfhbrook/node-ecstatic#259
How can you find out what version of Http server is running. I'm a newb, and am dealing with the same issue as most of you. Simply typing in to the cmd, npm install http-server@0.9.0 is not helping :(
I'm having the same issue. Rolled back to 0.9.0 fixed it.
@Shewolff182 it needs to be installed globally...you need the "-g"
npm install -g http-server@0.9.0
Confirmed the issue is due to http-server being incompatible ecstatic 3.3.2. Updating http-server's package.json to require ecstatic 3.3.1 fixes http-server for me.
@mikeycooper After edit the package.json, how we make npm change the ecstatic to 3.3.1? I'm a newbie. Could you please help?
@fx-pro rather than mucking with the package.json file, your best bet is to just install the older http-server 0.9.0, which doesn't have this problem.
npm install http-server@0.9.0
Yup, http-server at version 0.9.0 is working pretty good, like the old good days. Well, I didn't work in a npm module too much, but you can set a version as stable or downloadable for default? So when the user type npm install http-server
, the version npm will download is 0.9.0? Until we find a good solution for this.
@fx-pro rather than mucking with the package.json file, your best bet is to just install the older http-server 0.9.0, which doesn't have this problem.
npm install http-server@0.9.0
@mikeycooper Thank you for your response, I just asked for future problem.
Of course, I could install ecstatic@3.3.1 then manually copy it and replace the ecstatic inside http-server.
But it's really great if we can edit one line in package.json (in dependencies) and run some npm (?) to update it accordingly. [I try npm install in the http-server folder but the package folder become 100x bigger (300KB to 30MB) )
I'm having the same issue. Rolled back to 0.9.0 fixed it.
@Shewolff182 it needs to be installed globally...you need the "-g"
npm install -g http-server@0.9.0
Actually, while running http-server@0.11.1
locally brings up the same issues as everyone else has, running the same version of http-server
globally actually works as expected.
This resolv my problem
PS C:\myapp> node --version
v12.2.0PS C:\myapp> npm --version
6.9.0PS C:\myapp> npm install -g http-server@0.9.0
this works !!!!
I have a similar issue on it.
Please, my source here is it.
(drwx-wx-wx) | Drop Box/ | ||
---|---|---|---|
(-rw-r--r--) | 0B | .localized |
Node.js v12.5.0/ ecstatic server running @ 127.0.0.1:8080
Better to just navigate to localhost:8080/index.html
Better to just navigate to
localhost:8080/index.html
@danielstern thank you for the reply,
Addition, I tested chrome --> to ---> Mozilla
Now is working well.
I had same issue with Ubuntu 18.04, with http-server-legacy kind of also fixed, but prefered thus one.
This indeed solved my issue, but still in dist is not produced any index.html
This resolve my problem
PS C:\myapp> node --version
v12.2.0PS C:\myapp> npm --version
6.9.0PS C:\myapp> npm install -g http-server@0.9.0
I have just installed the older version and it worked but it has a security vulnerability in this version,
If you are just using for some local development then it's fine.
First, uninstall the existing
npm uninstall -g http-server
Install version 0.9.0
npm install http-server@0.9.0
I have just installed the older version and it worked but it has a security vulnerability in this version,
If you are just using for some local development then it's fine.
First, uninstall the existing
npm uninstall -g http-server
Install version 0.9.0
npm install http-server@0.9.0
if so how to use latest version?
in the folder path use the file name too and it work
like \project\index.html
in the folder path use the file name too and it work
like \project\index.html
Of course it will work. All web servers work this way.
The point is index.html is a magic file. It should be the default entry point if not specified.
On the cmd just type:
http-server [copy and paste the path of your project here] like:
http-server C:\Users\JOSE\Desktop\app
within the folder should have an index.html file at least.
This resolv my problem
PS C:\myapp> node --version
v12.2.0PS C:\myapp> npm --version
6.9.0PS C:\myapp> npm install -g http-server@0.9.0
npm install -g http-server@0.9.0 and it will work
downgrading to http-server 0.9.0 fixed my issue too
I had tha same problem, and i used the Incognito Mode in Google Chrome, it`s working)))))))
This resolv my problem
PS C:\myapp> node --version
v12.2.0PS C:\myapp> npm --version
6.9.0PS C:\myapp> npm install -g http-server@0.9.0
It works well! Thank you
Looks like this is due to jfhbrook/node-ecstatic#260.
If you're using nvm, just install another version of node and try again. It worked for me.
I think the issue is somehow related to directories.
When I enter
http://localhost:8080
, I get the same error, however requestinghttp://localhost:8080/index.html
directly works.A weird thing happens when I request a directory under the root. When I go to
http://localhost:8080/folder
it redirects me to this address:
http://localhost:8080/folder///////////////////
and produces this error:This page isnβt working
localhost redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
Thanks man. it works when i added /index.html.
To sump up : 2 work arounds :
- adding /index.html which is not acceptable as solution
- downgrading to V0.9.0 which is neither a good solution, since we're skiping the fixed issues since then
So : is there an upcomping V0.12 including this blocker ?
Sum up of current workarounds here:
In my case the latest version 0.11.1
creates a server with a random port. e.g. 20673
.
The version 0.9.0
works as expected with the default port 8080
. Should I open an issue?
btw. I can confirm the invalid redirect error. This brought me here. Maybe the random port has to do with the same reason.
Running on Windows 10 this is what worked for me:
Actual Result:
- I was getting ERR_INVALID_REDIRECT when building my React application hosting it using http-server version 0.11.1
Steps that fixed my issue
Downgrade ecstatic to version 3.0.0
- npm uninstall -g ecstatic
- npm install ecstatic@3.0.0
I'm having exactly the same error as @captainturtle,my system is windows10@17763.678,my win7 works fine.
Exactly the same error, my solution:
npm i -g serve
serve dist
LOL
The issue start at 3 May, not be fixed yet, it's irresponsibility.
Are you guys gonna fix this? Just force ecstatic to be 3.0.0 in http-server's package json as it clearly doesn't work with with latest 3.whatever. This shouldn't be up to the user of http-server to fix version in their package.json, we do not even use ecstatic. By the way, setting it to 4.1.2 also helped.
@waterplea we're slowly working on a rewrite without ecstatic in the reboot branch. However, the three of us active maintainers don't have a ton of free time. Plus, personally I never use Windows whatsoever, so I'm lacking the motivation of this issue directly affecting my workflow.
We greatly welcome help on the rewrite! I can probably throw together a "rewrite goals" doc on that branch to give an idea of where we're going.
I know you know ('cause sadly, no one gonna fix ecstatics...), but still.. just for the record..
This issue is still present.
http-server@0.11.1
Windows 10 v1903 64bit
tested in Firefox 69.0 and Chrome 76.0
Anyway, I confirm that setting ecstatic dependency to (exactly) 4.1.2 also solves the problem, so this might be an easy fix to do?
Same here, issue still present.
I also modified the package.json of http-server to require version 3.3.0 of ecstatic.
Somehow it just went for 1.4.1 or higher of ecstatic.
EDIT.:
Well I thought it fixed it but it still doesn't work. Oh well, back to bugfixing.
+1
ecstatic 4.1.2 may fix this issue, but it breaks a few other things which would affect more than just Windows users.
Is it possible to use http-server from WSL on Windows?
The issue is still present.
Only on windows 10, when tested on Mac it worked perfectly...
Just push an update that fixes the ecstatic
version at a working version, if the reboot branch is unlikely to be released in the near future.
C:\
Ξ» cat %APPDATA%\npm\node_modules\http-server\package.json | grep "ecstatic"
"ecstatic": "3.3.1",
C:\
Ξ» http-server
Starting up http-server, serving ./
Available on:
[REDACTED]
Hit CTRL-C to stop the server
[2019-09-23T11:52:07.281Z] "GET /" "[REDACTED]"
(node:2372) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
http-server stopped.
C:\
Ξ» node --version
v12.10.0
Follow-up from one of my students, who says that using
http://localhost:8080
causes the bug, but explicitly usinghttp://localhost:8080/index.html
works.
Thanks, the reason i had this issue is bcs didnt have default route in my aurelia project.
I'm serving the current directory. I tried with an index.html with an empty body, but I still get ERR_INVALID_REDIRECT. I'm at work so it could possibly be a proxy issue or something. I can try again at home later today to see if I get the same behavior.
ng serve --host 127.0.0.1 --port 8080
Follow-up from one of my students, who says that using
http://localhost:8080
causes the bug, but explicitly usinghttp://localhost:8080/index.html
works.Thanks, the reason i had this issue is bcs didnt have default route in my aurelia project.
ng serve --host 127.0.0.1 --port 8080
Above problems... use this command...
ng serve --host 127.0.0.1 --port 8080