Skip to content

ng serve error localhost could NOT be bound #2587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
phipso opened this issue Oct 8, 2016 · 10 comments
Closed

ng serve error localhost could NOT be bound #2587

phipso opened this issue Oct 8, 2016 · 10 comments
Labels
needs: more info Reporter must clarify the issue

Comments

@phipso
Copy link

phipso commented Oct 8, 2016

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Mac OSX El Capitan

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.16
node: 4.6.0
os: darwin x64

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
A lot of changes but the backend guy can work with cli and use ng serve

The log given by the failure.

Normally this include a stack trace and some more information.

ng serve

Provided host localhost could NOT be bound. Please provide a different host address or hostname
Error: Provided host localhost could NOT be bound. Please provide a different host address or hostname
at Error (native)
at /usr/local/lib/node_modules/angular-cli/node_modules/portfinder/lib/portfinder.js:139:27
at /usr/local/lib/node_modules/angular-cli/node_modules/portfinder/node_modules/async/lib/async.js:52:16
at /usr/local/lib/node_modules/angular-cli/node_modules/portfinder/node_modules/async/lib/async.js:264:21
at /usr/local/lib/node_modules/angular-cli/node_modules/portfinder/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/angular-cli/node_modules/portfinder/lib/portfinder.js:117:16
at Server.onError (/usr/local/lib/node_modules/angular-cli/node_modules/portfinder/lib/portfinder.js:54:14)
at Server.g (events.js:260:16)
at emitOne (events.js:77:13)
at Server.emit (events.js:169:7)
at emitErrorNT (net.js:1269:8)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)

Mention any other details that might be useful.


Thanks for your help

@filipesilva
Copy link
Contributor

It seems like there is some problem binding to localhost. Can you try ng serve --host 0.0.0.0 instead?

@filipesilva filipesilva added the needs: more info Reporter must clarify the issue label Oct 10, 2016
@phipso
Copy link
Author

phipso commented Oct 10, 2016

surfer-172-29-10-205-server:frontend philipplubeck$ ng serve --host 0.0.0.0
** NG Live Development Server is running on http://0.0.0.0:4200. **
4489ms building modules 4ms add1ms 92% chunk asset optimization/usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/node_modules/source-map/lib/source-map-consumer.js:704
throw new Error('"' + aSource + '" is not in the SourceMap.');
^
Error: "/usr/local/lib/node_modules/angular-cli/node_modules/angular2-template-loader/index.js!/Users/philipplubeck/frontend/src/app/gearslist.service.ts" is not in the SourceMap.
at SourceMapConsumer_sourceContentFor as sourceContentFor
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/node_modules/source-map/lib/source-node.js:133:40
at Array.forEach (native)
at Function.SourceNode_fromStringWithSourceMap as fromStringWithSourceMap
at SourceMapSource.node (/usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/SourceMapSource.js:42:20)
at ReplaceSource.node (/usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/ReplaceSource.js:66:29)
at CachedSource.node (/usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/CachedSource.js:12:23)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/ConcatSource.js:40:49
at Array.map (native)
at ConcatSource.node (/usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/ConcatSource.js:39:60)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/ConcatSource.js:40:49
at Array.map (native)
at ConcatSource.node (/usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/ConcatSource.js:39:60)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/ConcatSource.js:40:49
at Array.map (native)
at ConcatSource.node (/usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/ConcatSource.js:39:60)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/ConcatSource.js:40:49
at Array.map (native)
at ConcatSource.node (/usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/ConcatSource.js:39:60)
at ConcatSource.proto.sourceAndMap (/usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/SourceAndMapMixin.js:28:18)
at CachedSource.sourceAndMap (/usr/local/lib/node_modules/angular-cli/node_modules/webpack-sources/lib/CachedSource.js:51:28)
at Compilation. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/SourceMapDevToolPlugin.js:57:32)
at Array.map (native)
at Compilation. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/SourceMapDevToolPlugin.js:43:84)
at Array.forEach (native)
at Compilation. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/SourceMapDevToolPlugin.js:42:11)
at Compilation.applyPlugins (/usr/local/lib/node_modules/angular-cli/node_modules/tapable/lib/Tapable.js:25:14)
at Compilation. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:611:10)
at next (/usr/local/lib/node_modules/angular-cli/node_modules/tapable/lib/Tapable.js:81:11)
at Compilation. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/ProgressPlugin.js:118:5)
at Compilation.applyPluginsAsync (/usr/local/lib/node_modules/angular-cli/node_modules/tapable/lib/Tapable.js:85:13)
at Compilation. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:607:9)
at next (/usr/local/lib/node_modules/angular-cli/node_modules/tapable/lib/Tapable.js:81:11)
at Compilation. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/ProgressPlugin.js:114:5)
at Compilation.applyPluginsAsync (/usr/local/lib/node_modules/angular-cli/node_modules/tapable/lib/Tapable.js:85:13)
at Compilation. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:603:8)
at next (/usr/local/lib/node_modules/angular-cli/node_modules/tapable/lib/Tapable.js:81:11)
at Compilation. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/ProgressPlugin.js:110:5)
at Compilation.applyPluginsAsync (/usr/local/lib/node_modules/angular-cli/node_modules/tapable/lib/Tapable.js:85:13)
at Compilation.seal (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:551:7)
at Compiler. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compiler.js:436:15)
at /usr/local/lib/node_modules/angular-cli/node_modules/tapable/lib/Tapable.js:152:11
at Compilation. (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:444:10)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:420:12
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:332:10
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:52:16
at done (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:246:17)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:332:10
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:52:16
at done (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:246:17)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:332:10
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:52:16
at done (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:246:17)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:332:10
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:52:16
at done (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:246:17)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:332:10
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:52:16
at done (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:246:17)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:332:10
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:52:16
at done (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:246:17)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:332:10
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:52:16
at done (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:246:17)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:44:16
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:332:10
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:52:16
at Object.async.forEachOf.async.eachOf (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:236:30)
at Object.async.forEach.async.each (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/node_modules/async/lib/async.js:209:22)
at Compilation.addModuleDependencies (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:192:8)
at Compilation.processModuleDependencies (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:177:7)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:314:12
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:124:4
at Array.forEach (native)
at callback (/usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:123:12)
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/Compilation.js:147:10
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/NormalModule.js:203:10
at /usr/local/lib/node_modules/angular-cli/node_modules/webpack/lib/NormalModule.js:158:10
at /usr/local/lib/node_modules/angular-cli/node_modules/loader-runner/lib/LoaderRunner.js:365:3
at iterateNormalLoaders (/usr/local/lib/node_modules/angular-cli/node_modules/loader-runner/lib/LoaderRunner.js:206:10)
at /usr/local/lib/node_modules/angular-cli/node_modules/loader-runner/lib/LoaderRunner.js:197:4
at Storage.finished (/usr/local/lib/node_modules/angular-cli/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:39:16)
at /usr/local/lib/node_modules/angular-cli/node_modules/enhanced-resolve/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose as oncomplete

@filipesilva
Copy link
Contributor

It looks like using 0.0.0.0 solved your original issue. The followup is a dupe of #1982.

@renjithaby
Copy link

renjithaby commented Dec 1, 2016

getting an 403 Forbidden: incorrect proxy service was requested error, while loading the page on the server : "http://0.0.0.0:4200". Any help please.

Fix (incase, if anyone got stumbled like me) : use your ip instead of "0.0.0.0" while loading the page ie "your ip":4200.

@craig-o-curtis
Copy link

localhost:4200 was working before. Is there a way to get that working again rather than do the lengthy 0.0.0.0 hack?

@doronsever
Copy link

doronsever commented Nov 23, 2017

If someone still phasing this(mac os), you need to edit /etc/hosts and make sure you have this line:
127.0.0.1 localhost

@hidaytrahman
Copy link

ng serve --host 0.0.0.0

This happens when you change custom hostname

@aloksaxena
Copy link

I faced the same issue. I tried everything but nothing workout. Even I created a fresh project, but ng-serve failed. Then you know what I did, hope it may work for you.
in Host file: added this line: your machine IP with localhost e.g
10.XXX.XX.XXX localhost

@nhhockeyplayer
Copy link

nhhockeyplayer commented Jan 4, 2019

I have same issue... blue in the face nothing works and the /etc/hosts file is being hacked up
this is terrible they should review what they implemented so folks can serve up their apps from local office on SSL on a domain name with valid certificates all of which i have and still cannot run any ng serve --host

I have a node.js koa ssl server running fineon monogd with the domain name I purchased from rapidSSL and my host name serves up rest friendly JSON like butter off of the node.s koa server beautifully

Building and running the angular app with SSL certificates runs ok but I cannot go prod with LOCALHOST the url keeps saying connection is NOT private

So I need this --host option to work

and it wont

I can run xampp and that will intercept any hits to my domain name on port 80 over SSL at which point I proxy into my node.js but I cannot get this beyond localhost

Provided host mydomainname.com could NOT be bound. Please provide a different host address or hostname
Error: Provided host mydomainname.com could NOT be bound. Please provide a different host address or hostname

cli folks need to allocate a senior developer(s) to iron out this feature its preventing production in the field

ng serve --proxy-config proxy.conf.json --ssl true --ssl-cert "C:/xampp/apache/conf/certs/my.crt" --ssl-key "C:/xampp/apache/conf/cert
s/my.key" --open=true --host my.com --port=4200 --prod=false

???

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests

8 participants