Skip to content

Proxy assumes server can bind to IPv6 when specifying localhost #2330

Description

@tomjal

I updated from 0.9.5 to 1.0.5 and it says that:

"Proxy error: Could not proxy request /ui_host/api/v1/account/context from localhost:3000 to http://[::1]:5000/."

Any ideas?

Activity

  1. Timer commented on May 22, 2017

    @Timer
    Contributor

    Can you downgrade to 1.0.4 and try?

  2. Timer commented on May 22, 2017

    @Timer
    Contributor

    Normally, this error would mean that your server is not running on http://[::1]:5000/. Are you sure your server is running?

  3. tomjal commented on May 22, 2017

    @tomjal
    Author

    Im 100% sure that server works and is running properly. Im not sure what this [::1] means? My package.json has "proxy": "http://localhost:5000"

  4. gaearon commented on May 22, 2017

    @gaearon
    Contributor

    What does your proxy config look like?

  5. Timer commented on May 22, 2017

    @Timer
    Contributor

    [::1] is the IPv6 equivalent of localhost.

    @tomjal can you try changing your proxy property from localhost to 127.0.0.1?
    What host are you binding to with your application running on 5000?

    If your application on 5000 is binding to 127.0.0.1 and you're specifying localhost in your proxy, this is expected to not work.

  6. tomjal commented on May 22, 2017

    @tomjal
    Author

    @Timer you were right, it works with 127.0.0.1. The server is .NET Core Kestrel and for some reason it does not work with IPv6. Thanks

  7. Timer commented on May 22, 2017

    @Timer
    Contributor

    I'm going to reopen this because I think we can make this smarter.
    We resolve localhost to IPv6 because normally that's what it is, but that is obviously painful for servers that don't support it.
    I think we should act more in line with the underlying network and try both, or only perform this resolution when you're offline.

  8. reopened this on May 22, 2017
  9. added this to the 1.0.x milestone on May 22, 2017
  10. changed the title [-]Proxy not working in version 1.0.x ?[/-] [+]Proxy assumes server can bind to IPv6 when specifying localhost[/+] on May 22, 2017
  11. Timer commented on May 22, 2017

    @Timer
    Contributor

    What version of .NET core are you on? This announcement seems relevant: aspnet/Announcements#185.

    Configuring Kestrel to bind to localhost used to only bind to the IPv4 loopback interface. This caused confusion among users, especially those putting Kestrel behind reverse proxies that would see failures or delays because the proxies where trying to establish an IPv6 connection to Kestrel on localhost.

    Seems like in >=1.0.0 they fixed their bug and bind to [::1] as well. If they don't, this may be a regression on their part.

  12. uvtzxpm commented on May 22, 2017

    @uvtzxpm

    For what it's worth, I had exactly the same problem with a Google App Engine (dev_appserver.py) backend. I fixed it by changing the proxy from localhost to 127.0.0.1, as already suggested.

    There might be other strange and wonderful servers that people are using that can be affected by this.

  13. Timer commented on May 23, 2017

    @Timer
    Contributor

    While inspecting these individual cases, it's amazing how deep into the rabbit hole you can go.

    In @uvtzxpm's case, dev_appserver.py connects to localhost but Python 2 by default doesn't enable IPv6 (you have to configure it with --enable-ipv6; Python 3 has it on by default afaik).

    Most of this testing was done with Node servers on windows which do support IPv6.

  14. Timer commented on May 23, 2017

    @Timer
    Contributor

    I went ahead and did some testing on Windows.

    So it seems that localhost is resolvable as long as you're on a network, but not necessarily online.
    Since this is the case, we don't really want to resolve localhost to something else if we're not on a network.

    If we're not on a network, we are going to be super safe and assume 127.0.0.1.

    See #2332.

  15. Timer commented on May 23, 2017

    @Timer
    Contributor

    @uvtzxpm can you manually patch your files with that PR and make sure it works when you switch back to localhost?
    @tomjal would appreciate if you could try too.

  16. modified the milestones: 1.0.6, 1.0.x on May 24, 2017
  17. gaearon commented on May 24, 2017

    @gaearon
    Contributor
  18. uvtzxpm commented on May 24, 2017

    @uvtzxpm

    @Timer I can confirm that using localhost works for me using 1.0.6, thanks.

  19. locked and limited conversation to collaborators on Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions