Angularjs 2 project development with angular-cli



New to cloud9 and trying out my first project using something for a class I’m taking.
This uses the angular-cli and my basic question is, when I run ‘ng serve --host --port 8080’ (as found in other threads), it runs, but what browser and what url do I run this in within the context of cloud9? When run locally, I can simply hit (with default cli settings) http://localhost:4200 , but of course this doesn’t make sense from within the virtual dev environment, unless of course there’s a browser running within this vm too which would be interesting…


Okay, figured it out, by using the preview tab.
However, unlike running locally, changes to my code aren’t picked up dynamically and reloaded? Means I have stop and start the server on any change?


Correct. Unless you are running a static HTML/CSS/JS page without a server then you’ll have to reload your own.


https ://


i cant run app using angular2 cli, getting “Invalid Host header” error.


I followed the steps , everythings seems to be good but when I tried running my app using preview button, im getting "Invalid Host header " and url show on c9 browser is
any help is appreciated.


Yes, that’s due to a recent change in security for Webpack dev server that Ng uses. You now have to specify --host <workspace>-<username>, and add an entry <workspace>-<username> to /etc/hosts. If you reload the workspace, it may migrate to a different host and then you need to add that entry again.

I believe they are working on a fix: to enable --public option for Webpack dev server.

Btw, the url should be simply https://<workspace>-<username> (and you can remove the :8080 part if browsed from IDE tab).


Thanks dinvlad for quick response. I ma still getting this error

“Provided host could NOT be bound. Please provide a different host address or hostname”

when i fire command prfpp:~/workspace/my-app (master) $ ng serve --host


also , looks like I dont have write access to add host entry in /etc/hosts.


Hi, i am getting the same message, could you fix that?

-Thank you.


You can now use

ng serve -p 8080 -H --public-host ${HOST}

where HOST=<your_c9_project_name>-<your_c9_user_name>

Preview just gave up the ghost

Thank you very much, this worked for me.


No problem, here’s the relevant discussion on GIthub:


Huh, so I had made no changes to my workspace (didn’t upgrade any modules, etc.) but one day it was working fine without this host addition, the next it wasn’t. Curious how that can be?


so this issue (starting servers in frameworks running on this service) has become one of the most problematic and difficult issues I’ve dealt with on cloud9. This one I thought I had figured out, had an alias macro defined for it and didn’t have to worry about it… and now apparently have to go back and rejigger it to fix it.

It would be very nice if cloud9 could provide some sort of wrapper/macro library that would do this for some of the more popular frameworks and take the guesswork out of the clients hands. This is making the choice of using a remote system like this (which I was hoping to be convenient and portable) vs. a local setup a lot less enticing.


This worked for me 31-1-2018