3

I created a simple angular app and it's now serving on my Linux server by npm start (Development mode)

The problem here is that it is unreachable through the browser. The 4200 port is open too.

The app works perfect on the local computer through the address http://localhost:4200.

Now I tried to access the app on the server through http://xxx.xx.xx.xx:4200

enter image description here

This is the console output when the npm start command run.

> [email protected] start /var/www/html/node1/social2/client > ng serve Unable to find "@angular/cli" in devDependencies. The package "angular-cli" has been deprecated and renamed to "@angular/cli". Please take the following steps to avoid issues: "npm uninstall --save angular-cli" ** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ ** Date: 2018-01-23T19:40:09.118Z Hash: 0698820565e2563b7f26 Time: 16593ms chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered] chunk {main} main.bundle.js (main) 178 kB [initial] [rendered] chunk {polyfills} polyfills.bundle.js (polyfills) 550 kB [initial] [rendered] chunk {styles} styles.bundle.js (styles) 33.8 kB [initial] [rendered] chunk {vendor} vendor.bundle.js (vendor) 9.15 MB [initial] [rendered] webpack: Compiled successfully. 

What could be the reason for this ?

6
  • 3
    If you're trying to hide your IP, you might want to update that screenshot. Commented Jan 23, 2018 at 19:58
  • You need to listen on 0.0.0.0 for it to be reachable externally. Commented Jan 23, 2018 at 20:02
  • In the package.json update start to ng serve --host 0.0.0.0 github.com/angular/angular-cli/issues/3765 Commented Jan 23, 2018 at 20:02
  • Possible duplicate of TypeError: Cannot read property 'config' of null Commented Jan 23, 2018 at 20:54
  • You've asked the same exact question twice, yourself. What are you doing Commented Jan 23, 2018 at 20:55

3 Answers 3

1

The hostname and port you provided are not reachable . from outside of your Linux machine.

ng serve default value is targeting localhost.

Please change it to :

ng serve --host 0.0.0.0 
Sign up to request clarification or add additional context in comments.

1 Comment

I dont think this is best practises. You may want to set there the IP address you really plan to use
0

You need to deploy the dist folder created after you do ng build --prod localy, and then access the app via index.html

Comments

0

if your using a linux server check your ip address using ifconfig if your using windows run ipconfig copy your ip address then run

ng s --host <ip address> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.