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

connect ehostunreach 0.0.31.153:80 #1514

Closed
carvalhoviniciusluiz opened this issue May 1, 2018 · 8 comments
Closed

connect ehostunreach 0.0.31.153:80 #1514

carvalhoviniciusluiz opened this issue May 1, 2018 · 8 comments

Comments

@carvalhoviniciusluiz
Copy link

Hi, I have a project with restify that sends data to an api with axios. When I start both apis locally the axios shows this message

{ Error: connect EHOSTUNREACH 0.0.31.153:80 - Local (192.168.2.112:64676)
    at Object._errnoException (util.js:1024:11)
    at _exceptionWithHostPort (util.js:1046:20)
    at internalConnect (net.js:971:16)
    at GetAddrInfoReqWrap.emitLookup [as callback] (net.js:1106:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:97:10)
  code: 'EHOSTUNREACH',
  errno: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '0.0.31.153',
  port: 80

I noticed that this post #1228 is similar to mine, but it's closed.
How do you solve this?

environment

os: macOS
node: v8.9.3
npm: 5.5.1
axios: 0.18.0

@koresar
Copy link

koresar commented May 17, 2018

IP addresses can't start with 0. Thus the EHOSTUNREACH error. See here for example: https://superuser.com/questions/665502/why-cant-ip-addresses-start-with-0-or-255

This issue should be closed.

@carvalhoviniciusluiz
Copy link
Author

but the local ip does not begin with 0. As it is construction, the project is raised in the local address (localhost or 127.0.0.1)

this message is not making sense because of this

@koresar
Copy link

koresar commented May 21, 2018

You'd need to find why the address is

address: '0.0.31.153',

@mapleeit
Copy link

mapleeit commented May 29, 2018

Hi @carvalhoviniciusluiz , I encountered this problem today. By doing debug, I found some reason may cause this problem.

It's about your system bash/zsh proxy settings

export https_proxy=localhost:8888
export http_proxy=localhost:8888

axios will automatically detect your default proxys and use them.

axios/lib/adapters/http.js

var proxy = config.proxy;
    if (!proxy) {
      var proxyEnv = protocol.slice(0, -1) + '_proxy';
      var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
      if (proxyUrl) {
        var parsedProxyUrl = url.parse(proxyUrl);
        proxy = {
          host: parsedProxyUrl.hostname,
          port: parsedProxyUrl.port
        };

        if (parsedProxyUrl.auth) {
          var proxyUrlAuth = parsedProxyUrl.auth.split(':');
          proxy.auth = {
            username: proxyUrlAuth[0],
            password: proxyUrlAuth[1]
          };
        }
      }
    }

the result of url.parse('localhost:8888'):

image

get the wrong hostname

Then your dns will find this hostname, as a result, it returns 0.0.xx.xxx, which throw errors.

so just remove https_proxy and http_proxy and restart your terminal

@GabrieleRomeo
Copy link

so just remove https_proxy and http_proxy and restart your terminal

For the sake of simplicity, you can remove them in the following way:

npm config delete http-proxy
npm config delete https-proxy

@yey
Copy link

yey commented Nov 21, 2018

so just request http:// 0.0.0.0:1337/your/path
then url will be right

@Kabil-Boutou
Copy link

This error is also fired when you write just the IP @ without the protocol.
Even with 127.0.0.1 you should add http://.
Hope that was helpful .

@jsina
Copy link

jsina commented Nov 27, 2019

I've just add the http:// before the endpoint url and problem is solved then.

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants