{"action":"created","issue":{"url":"https://api.github.com/repos/nwjs/nw.js/issues/3115","labels_url":"https://api.github.com/repos/nwjs/nw.js/issues/3115/labels{/name}","comments_url":"https://api.github.com/repos/nwjs/nw.js/issues/3115/comments","events_url":"https://api.github.com/repos/nwjs/nw.js/issues/3115/events","html_url":"https://github.com/nwjs/nw.js/issues/3115","id":58456353,"number":3115,"title":"EADDRINUSE from within node context (node-main)","user":{"login":"diimdeep","id":485713,"avatar_url":"https://avatars.githubusercontent.com/u/485713?v=3","gravatar_id":"","url":"https://api.github.com/users/diimdeep","html_url":"https://github.com/diimdeep","followers_url":"https://api.github.com/users/diimdeep/followers","following_url":"https://api.github.com/users/diimdeep/following{/other_user}","gists_url":"https://api.github.com/users/diimdeep/gists{/gist_id}","starred_url":"https://api.github.com/users/diimdeep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diimdeep/subscriptions","organizations_url":"https://api.github.com/users/diimdeep/orgs","repos_url":"https://api.github.com/users/diimdeep/repos","events_url":"https://api.github.com/users/diimdeep/events{/privacy}","received_events_url":"https://api.github.com/users/diimdeep/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-02-21T11:35:10Z","updated_at":"2015-04-21T05:36:21Z","closed_at":"2015-02-21T15:47:34Z","body":"package.json:\r\n```\r\n    \"main\": \"app/index.html\",\r\n    \"node-main\": \"app/index.js\",\r\n```\r\nindex.js:\r\n```\r\nexports.init = function() {\r\n    var httpProxy = require('http-proxy')\r\n\r\n    default_router =  {\r\n    }\r\n    var router = default_router\r\n\r\n    var options = {\r\n        router: router\r\n    }\r\n\r\n    var proxyServer = httpProxy.createServer(options);\r\n    proxyServer.listen(8088);\r\n};\r\n```\r\n\r\nIf run function from index.html - OK.\r\n```\r\n    <script>\r\n        process.mainModule.exports.init();\r\n    </script>\r\n```\r\nif run function from node-main:\r\n\r\n```\r\n[16966:0221/142943:ERROR:nw_shell.cc(325)] Error: listen EADDRINUSE :::8088\r\n    at Object.exports._errnoException (util.js:734:11)\r\n    at exports._exceptionWithHostPort (util.js:757:20)\r\n    at Server._listen2 (net.js:1153:14)\r\n    at listen (net.js:1179:10)\r\n    at Server.listen (net.js:1266:5)\r\n    at ProxyServer.listen (node_modules/http-proxy/lib/http-proxy/index.js:135:16)\r\n    at Object.exports.init (app/index.js:35:17)\r\n    at Object.<anonymous> (app/index.js:38:9)\r\n    at Module._compile (module.js:451:26)\r\n    at Object.Module._extensions..js (module.js:469:10)\r\n```"},"comment":{"url":"https://api.github.com/repos/nwjs/nw.js/issues/comments/94644081","html_url":"https://github.com/nwjs/nw.js/issues/3115#issuecomment-94644081","issue_url":"https://api.github.com/repos/nwjs/nw.js/issues/3115","id":94644081,"user":{"login":"drschwabe","id":858841,"avatar_url":"https://avatars.githubusercontent.com/u/858841?v=3","gravatar_id":"","url":"https://api.github.com/users/drschwabe","html_url":"https://github.com/drschwabe","followers_url":"https://api.github.com/users/drschwabe/followers","following_url":"https://api.github.com/users/drschwabe/following{/other_user}","gists_url":"https://api.github.com/users/drschwabe/gists{/gist_id}","starred_url":"https://api.github.com/users/drschwabe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drschwabe/subscriptions","organizations_url":"https://api.github.com/users/drschwabe/orgs","repos_url":"https://api.github.com/users/drschwabe/repos","events_url":"https://api.github.com/users/drschwabe/events{/privacy}","received_events_url":"https://api.github.com/users/drschwabe/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T05:36:21Z","updated_at":"2015-04-21T05:36:21Z","body":"Same problem with this simple express example, runs fine in vanilla node: \r\n```\r\nvar express = require('express'),\r\n    app = express()\r\n\r\nvar server = app.listen( 5001 , function() {\r\n  console.log('Listening on ' + server.address().port);\r\n})\r\n```\r\nBut throws error in nw: \r\n```\r\nevents.js:125\r\n      throw er; // Unhandled 'error' event\r\n            ^\r\nError: listen EADDRINUSE :::5001\r\n    at Object.exports._errnoException (util.js:734:11)\r\n    at exports._exceptionWithHostPort (util.js:757:20)\r\n    at Server._listen2 (net.js:1153:14)\r\n    at listen (net.js:1179:10)\r\n    at Server.listen (net.js:1266:5)\r\n    at EventEmitter.app.listen (/home/derrick/dev/g/scrollcraft/demos/nw/node_modules/express/lib/application.js:595:24)\r\n    at Object.<anonymous> (/home/derrick/dev/g/scrollcraft/demos/nw/server.js:4:18)\r\n    at Module._compile (module.js:451:26)\r\n    at Object.Module._extensions..js (module.js:469:10)\r\n    at Module.load (module.js:346:32)\r\n[23325:0420/220710:ERROR:channel.cc(305)] RawChannel read error (connection broken)\r\n```\r\nexpress does not require node-http-proxy as a dependency. "}}