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

Can't see homepage at localhost:4000 #1349

Closed
ekkapob opened this issue Nov 11, 2015 · 32 comments · May be fixed by XirdigH/phoenix-1#8
Closed

Can't see homepage at localhost:4000 #1349

ekkapob opened this issue Nov 11, 2015 · 32 comments · May be fixed by XirdigH/phoenix-1#8

Comments

@ekkapob
Copy link

ekkapob commented Nov 11, 2015

I can't browse to homepage. I followed Phoenix Up & Running instructions with no errors so far. However, when I browse to the homepage port 4000, nothing show up, like no connection at all. I tried with different ports (ref: #962) but no luck.

Chrome: This webpage is not available ERR_CONNECTION_REFUSED
Firefox: Unable to connect - Firefox can't establish a connection to the server at localhost:4000..

All commands run without errors

➜ mix ecto.create
The database for HelloPhoenix.Repo has been created.

➜ mix phoenix.server
[info] Running HelloPhoenix.Endpoint with Cowboy on http://localhost:4000
12 Nov 01:30:57 - info: compiled 5 files into 2 files, copied 3 in 3480ms
@chrismccord
Copy link
Member

try http://127.0.0.1:4000 and report back. Some users have have issues on localhost for one reason or another

@ekkapob
Copy link
Author

ekkapob commented Nov 11, 2015

120.0.0.1 works. Thanks @chrismccord for the lighting response. Do you have any clues why localhost doesn't work? Will check your irc.

@chrismccord
Copy link
Member

Awesome. I don't see how this is on our end, and I can't recreate locally so for now loopback address is a usable workaround. Hop on elixir-lang irc if you have any issues

@bbrock25
Copy link

I just experienced this issue as well on chrome but was able to use localhost on firefox.

@doomspork
Copy link
Contributor

This just recently happened to me, no other changes to the system. It occurred in the middle of running my Phoenix application. As a work around I've shifted to using lvh.me which maps to localhost and enables me to use subdomains.

There's been at least a half dozen folks with a similar issue in Slack. Would be great to figure out what's behind this. Tough to see it as a system issue when it's impacting more and more users of a particular framework and language. Hard to believe we all made the same mistakes, independent of OS, while using Phoenix.

@chrismccord
Copy link
Member

There's been at least a half dozen folks with a similar issue in Slack. Would be great to figure out what's behind this.

Unfortunately given how arbitrary this seems to come up with no means to recreate it, and often reported as browser dependent, I wouldn't know where to begin. I also don't have time to chase down this particular rabbit hole. If someone wants to take a deep-dive that would be fantastic.

@doomspork
Copy link
Contributor

I agree @chrismccord, that was a general statement. I've tried a handful of things I can't seem to make any headway. It's a perplexing problem but it does seem to be related in some way to Phoenix, Plug, Elixir, or Cowboy. Localhost works just fine for Ruby, Python, and Java applications.

@ianfleeton
Copy link

I had a similar issue and was able to continue using the same browser (Chrome) after clearing cache, cookies, etc., which made me think at the time it was a bad cookie or something tied to the domain name. I do a lot of other development on localhost so there could be all sorts being sent. I haven't had this happen again to confirm a better link.

@zlu
Copy link

zlu commented Mar 28, 2016

Probably something changed in /etc/hosts. Maybe add this back:

127.0.0.1 localhost

@doomspork
Copy link
Contributor

@zlu the /etc/hosts was never changed and the entry still exists. Since localhost:4000 works across other languages and frameworks that might suggest it's not a host issue 😀

@sjoonk
Copy link

sjoonk commented Jun 14, 2016

I think it's something related with cowboy not phoenix framework. And it's something related Chrome browser. On Safari, it works.

@joshhepworth
Copy link

I wanted to add some info to this, as I ran into this issue.

It seems that Chrome can connect, but will not render anything other than a totally empty page (view source shows no content). It worked without issue in Firefox and Safari.

I meant to delete cookies one by one to see if a particular cookie was causing the problem, however I accidentally wiped them all out – which did solve the problem. Deleting the cookies stored at localhost was the only change I made to get it working.

I also do Rails and Express development, so it's possible cookies set by one of those are interfering with something in the rendering stack. I'm super new to Phoenix dev, so I'm not sure where to look, but if I run into it again (and remember to delete cookies one by one), I'll add information here.

@josevalim
Copy link
Member

Yes, Cowboy simply discards the request for large headers because allowing otherwise is a possible attack vector. So erasing cookies is the way to go.

@joshhepworth
Copy link

Sounds like it's likely just related to one of the cookies being large in that list – I had cookies for 10+ different Rails projects in there, and I bet one or two were pushing 500bytes. Generally sounds like this might be related to this issue.

That being said, is there a way to adjust this number somehow (and what is the max size set to)? Seems like sometimes I'd want to be able to increase the number – plenty of sites have largish cookies, my browser is showing 5 on Amazon over 500bytes.

@josevalim
Copy link
Member

I believe the default is 4k. See here: https://ninenines.eu/docs/en/cowboy/1.0/manual/cowboy_protocol/index.html#max_header_value_length

You can change it by setting the following in your config.exs file (iirc):

http: [protocol_options: [max_header_value_length: 8192]]

@mnussbaumer
Copy link
Contributor

The empty white page on localhost:4000 just happened to me and I can confirm it's a cookie issue. I had previously created a new app with phoenix and localhost:4000 worked just fine. I deleted that app, created a new one, and it would work with 127.0.0.1:4000 but not with localhost:4000 - just a totally blank page. So what happened was that I was using exactly the same name as another app I had with Ruby On Rails, which in turn had a session cookie created for that app name and that conflicted with the new phoenix app. Erasing that cookie solved the issue, so if you're seeing a total blank screen when visiting localhost check to see if you don't happen to have a previously set cookie with the same name as the app you're currently trying to run.

@josevalim
Copy link
Member

Btw, this has been fixed in Plug v1.4 since it now warns on the terminal when this happens.

@mnussbaumer
Copy link
Contributor

It doesn't show anything when it's simply an existing cookie (without exceeding max length)?

Micaels-MacBook-Pro:dinastywars mnussbaumer$ mix phoenix.server
[info] Running Dinastywars.Endpoint with Cowboy using http://localhost:4000
27 Jul 20:53:33 - info: compiled 6 files into 2 files, copied 3 in 1.9 sec

Nothing was being output when I was hitting localhost:4000.

@josevalim
Copy link
Member

@mnussbaumer what is your plug version? Also, Plug will just log something if the server returns 400.

@mnussbaumer
Copy link
Contributor

Ahh you're right, sorry @josevalim - I just assumed I would have the latest version because I installed everything phoenix/elixir/erlang yesterday . Thanks - it reads plug 1.3.5 - I'm completely new to phoenix btw

@josevalim
Copy link
Member

No problem and welcome!

@mnussbaumer
Copy link
Contributor

Thanks, and for your work too - it looks great, sounds great and I will try to use it moving on from Rails - Besides the issues on github (since my knowledge is a bit more superficial) is there any way to contribute? Or mailing list? There are also some broken links, like http://phoenixframework.org/docs/understanding-plug and /community

@josevalim
Copy link
Member

The issues on github are the main way. For the guides, reach the phoenix_guides repo. The guides are currently being reworked for v1.3 so, if I assume they will need help with sanity checking everything as soon as it goes live.

@kkkkeeee
Copy link

kkkkeeee commented Nov 8, 2017

Hi, I am facing the same error. I tried to open localhost:4000 and 127.0.0.1:4000 on Chrome and Microsoft Edge on Windows. But still I cannot open the homepage.

Could anyone help me with it?

@mnussbaumer
Copy link
Contributor

@kkkkeeee can you provide some more info? Do you get a blank page? Or an error? What shows up on iex? And on the javascript console?

@kkkkeeee
Copy link

kkkkeeee commented Nov 8, 2017 via email

@OvermindDL1
Copy link
Contributor

It's usually better to ask questions like this on the forum for quicker responses.

But what is your git address so we can try out what you are trying so we can see the issue?

@vellmoss
Copy link

I worked through a VPN tunnel. Disconnected it - and everything became OK.

@OvermindDL1
Copy link
Contributor

I worked through a VPN tunnel. Disconnected it - and everything became OK.

Heh, sounds like the VPN is redirecting local connections, that is... very odd... ^.^;

@vellmoss
Copy link

when I looked at the page on F12 (Chrome), I saw in the tab "Application" tags:

@Awankelabu5566
Copy link

Done

@web-apply
Copy link

review here http://localhost:4000

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

Successfully merging a pull request may close this issue.

16 participants