6

I want to open my angular app other than localhost for my development purpose but running into below error, any guidance on how to fix it?

username$ ng serve --open --host=ibaitdev.company.com
getaddrinfo ENOTFOUND ibatdev.company.com
Error: getaddrinfo ENOTFOUND ibatdev.company.com
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)

I changed my /etc/hosts as below

#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       ibaitdev.company.com
255.255.255.255 broadcasthost
::1             ibaitdev.company.com
6
  • 1
    You can use any of those in your browser but you still need to append the correct port it is being served on in the browser URL Commented Aug 9, 2019 at 18:22
  • ibatdev is not ibaitdev. Spelling matters. Commented Aug 9, 2019 at 18:29
  • @Igor - but its throwing an error right?how do I use them in the browser URL?are you saying to add the port numbers in /etc/hosts ? Commented Aug 9, 2019 at 18:32
  • --host 0.0.0.0 could help? Commented Aug 9, 2019 at 18:33
  • 1
    You now changed the spelling in your question, but did you run ng serve with the correct hostname? The error output still shows ibatdev. Commented Aug 9, 2019 at 18:45

2 Answers 2

14

Using ng serve --host 0.0.0.0 --disable-host-check will allow you to connect to the server using your IP 0.0.0.0 instead of localhost.

This will disable host check and allow to access from outside with IP address instead of localhost.

In newer versions of the AngularCLI (higher than v5), you can use 0.0.0.0 as the IP again to host it on your network.

Sign up to request clarification or add additional context in comments.

Comments

5

You can do ng serve --host=127.0.0.1 and then when you go to your browser just go to that domain name. (127.0.0.1:4200)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.