Skip to content

Commit

Permalink
feat: Suggest adding domain to hosts file when connection fails
Browse files Browse the repository at this point in the history
When connecting to a local cozy-stack (i.e. `cozy.localhost:8080`), the
user should configure their `hosts` file. Otherwise they will get an
`getaddrinfo ENOTFOUND` error

People often get confused as their web browser success to access the
local cozy-stack. But some web browsers have their internal domain
resolution mechanism and so they may succeed to access the cozy-stack
without the `hosts` entry. A terminal cannot do that
  • Loading branch information
Ldoppea committed Sep 15, 2022
1 parent f8f646a commit 0f19c88
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libs/ACH.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ class ACH {
log.warn(
'You can specify the Cozy URL by using the --url argument: ACH --url http://bob.cozy.localhost:8080 '
)

if (this.url.includes('localhost')) {
log.warn(
`Seems like you are trying to connecto to a localhost server, please verify that this domain is declared in your system's hosts file (i.e. '127.0.0.1 bob.cozy.localhost')`
)
}

throw err
}
}
Expand Down

0 comments on commit 0f19c88

Please sign in to comment.