Description:
I create a new Project and try to run serve and lab. Serve works fine but when i use ionic lab the error appears.
Steps to Reproduce:
start Empty Project and run lab
Output:
> ionic-lab http://localhost:8100 --host localhost --port 8200 --app-name app --app-version 0.0.1
[lab] events.js:183
[lab] throw er; // Unhandled 'error' event
[lab] ^
[lab] Error: getaddrinfo ENOTFOUND localhost
[lab] at errnoException (dns.js:50:10)
[lab] at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
[ERROR] A utility CLI has unexpectedly closed (exit code 1).
The Ionic CLI will exit. Please check any output above for error details.
My ionic info:
Ionic:
ionic (Ionic CLI) : 4.0.3 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.11
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : none
System:
NodeJS : v8.11.3 (/usr/local/bin/node)
npm : 5.10.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
Environment:
ANDROID_HOME : not set
getaddrinfo ENOTFOUND localhost -> This error means localhost can't be resolved. This is likely an issue with your /etc/hosts file. Please see this article for fixing it on macOS: http://osxdaily.com/2014/04/12/restore-original-hosts-file-mac/
Basically, /etc/hosts must contain the following entries:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
Add below lines to your /etc/hosts file
##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
Most helpful comment
getaddrinfo ENOTFOUND localhost-> This error meanslocalhostcan't be resolved. This is likely an issue with your/etc/hostsfile. Please see this article for fixing it on macOS: http://osxdaily.com/2014/04/12/restore-original-hosts-file-mac/Basically,
/etc/hostsmust contain the following entries: