When not specifying port, browser-sync 2.7.13 will auto-detect port by incrementing from port 3000. If port 3000 but not 3001 is in use, EADDRINUSE is thrown as UI uses 3001 as default. Manually setting ui.port fixes this, but I guess ui.port should be auto-detected too.
Here is the debug output:
[BS] [debug] -> Starting Step: Finding an empty port
[BS] [debug] Found a free port: 3001
[BS] [debug] Setting Option: port - 3001
[BS] [debug] + Step Complete: Finding an empty port
[BS] [debug] -> Starting Step: Checking online status
[BS] [debug] Resolved www.google.com, setting online: true
[BS] [debug] Setting Option: online - true
[BS] [debug] + Step Complete: Checking online status
[BS] [debug] -> Starting Step: Resolve user plugins from options
[BS] [debug] + Step Complete: Resolve user plugins from options
[BS] [debug] -> Starting Step: Set Urls and other options that rely on port/onli
ne status
[BS] [debug] Setting multiple Options
[BS] [debug] + Step Complete: Set Urls and other options that rely on port/onli
ne status
[BS] [debug] -> Starting Step: Setting Internal Events
[BS] [debug] + Step Complete: Setting Internal Events
[BS] [debug] -> Starting Step: Setting file watchers
[BS] [debug] + Step Complete: Setting file watchers
[BS] [debug] -> Starting Step: Merging middlewares from core + plugins
[BS] [debug] Setting Option: middleware - List []
[BS] [debug] + Step Complete: Merging middlewares from core + plugins
[BS] [debug] -> Starting Step: Setting the rewrite rules middleware for snippet
[BS] [debug] + Step Complete: Setting the rewrite rules middleware for snippet
[BS] [debug] -> Starting Step: Starting the Server
[BS] [debug] Static Server running (http) ...
[BS] [debug] Running mode: SERVER
[BS] [debug] + Step Complete: Starting the Server
[BS] [debug] -> Starting Step: Starting the HTTPS Tunnel
[BS] [debug] + Step Complete: Starting the HTTPS Tunnel
[BS] [debug] -> Starting Step: Starting the web-socket server
[BS] [debug] Setting Option: clientEvents - List [ "scroll", "input:text", "inpu
t:toggles", "form:submit", "form:reset", "click" ]
[BS] [debug] + Step Complete: Starting the web-socket server
[BS] [debug] -> Starting Step: Adding the HTTP protocol
[BS] [debug] + Step Complete: Adding the HTTP protocol
[BS] [debug] -> Starting Step: Starting the UI
[BS] [UI] Starting Step: Setting default plugins
[BS] [UI] Step Complete: Setting default plugins
[BS] [UI] Starting Step: Finding a free port
[BS] [UI] Step Complete: Finding a free port
[BS] [UI] Starting Step: Setting options also relevant to UI from BS
[BS] [UI] Step Complete: Setting options also relevant to UI from BS
[BS] [UI] Starting Step: Setting available URLS for UI
[BS] [debug] Getting option via path: urls
[BS] [UI] Step Complete: Setting available URLS for UI
[BS] [UI] Starting Step: Starting the Control Panel Server
[BS] [UI] Using port 3001
[BS] [UI] Step Complete: Starting the Control Panel Server
[BS] [UI] Starting Step: Add element events
[BS] [UI] Step Complete: Add element events
[BS] [UI] Starting Step: Registering default plugins
[BS] [debug] Getting option via path: urls,external
[BS] [UI] Step Complete: Registering default plugins
[BS] [UI] Starting Step: Add options setting event
[BS] [UI] Step Complete: Add options setting event
[BS] [debug] + Step Complete: Starting the UI
[BS] [debug] -> Starting Step: Merge UI settings
[BS] [debug] Setting Option: urls - Map { "local": "http://localhost:3001", "ext
ernal": "http://10.10.10.37:3001", "ui": "http://localhost:3001", "ui-external":
"http://10.10.10.37:3001" }
[BS] [debug] + Step Complete: Merge UI settings
[BS] [debug] -> Starting Step: Init user plugins
[BS] [debug] Setting Option: userPlugins -
[BS] [debug] + Step Complete: Init user plugins
[BS] Access URLs:
------------------------------------
Local: http://localhost:3001
External: http://10.10.10.37:3001
------------------------------------
UI: http://localhost:3001
UI External: http://10.10.10.37:3001
------------------------------------
[BS] Serving files from: ..\build
[21:00:41] Finished 'server' after 7.92 s
[21:00:41] Starting 'default'...
[21:00:44] Finished 'default' after 3.4 s
events.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at exports._errnoException (util.js:746:11)
at Server._listen2 (net.js:1156:14)
at listen (net.js:1182:10)
at Server.listen (net.js:1267:5)
at Object.module.exports.startServer [as fn] (C:\Users\arves_000\Documents\GitHub\oppgaver\codeclub_lesson_builder\node_modules\browser-sync\node_modules\browser-sync-ui\lib\async.js:116:39)
at C:\Users\arves_000\Documents\GitHub\oppgaver\codeclub_lesson_builder\node_modules\browser-sync\node_modules\browser-sync-ui\lib\UI.js:181:14
at iterate (C:\Users\arves_000\Documents\GitHub\oppgaver\codeclub_lesson_builder\node_modules\browser-sync\node_modules\async-each-series\index.js:8:5)
at C:\Users\arves_000\Documents\GitHub\oppgaver\codeclub_lesson_builder\node_modules\browser-sync\node_modules\async-each-series\index.js:16:16
at C:\Users\arves_000\Documents\GitHub\oppgaver\codeclub_lesson_builder\node_modules\browser-sync\node_modules\browser-sync-ui\lib\UI.js:189:13
at Object.module.exports.setUrlOptions [as fn] (C:\Users\arves_000\Documents\GitHub\oppgaver\codeclub_lesson_builder\node_modules\browser-sync\node_modules\browser-sync-ui\lib\async.js:72:9)
Windows 8.1
node 0.12.7
browser-sync 2.7.13
+1
Any progress on this? I am using gulp, and it seems that the regular port auto-detects correctly, but the UI port does not, and throws an EADDRINUSE. At least, it does not auto-detect on the first try, but it usually works on the second try. It does not seem to be dependent on the timing: whether I try the 2nd server after 5 seconds or 10 minutes, the error still shows up. I don't know about the weinre port, but since I have not seen any errors related to it, I'm assuming either all weinre instances use the same port, or whenever the ui port succeeds in auto-incrementing, the weinre port does, too.
The error fails my gulp task, even with watch running. I could probably find a way to catch it, though I believe it calls process.exit, which makes it much harder, and/or auto-detect the port myself, but since BrowserSync already does this, albeit in a slightly buggy way, I would rather it stay in BrowserSync, if possible.
+1
Any luck? This issue still occurs for me. Surprising since it's been nearly 2 years. I'm happy to help any way I can.
Most helpful comment
Any progress on this? I am using
gulp, and it seems that the regularportauto-detects correctly, but the UI port does not, and throws anEADDRINUSE. At least, it does not auto-detect on the first try, but it usually works on the second try. It does not seem to be dependent on the timing: whether I try the 2nd server after 5 seconds or 10 minutes, the error still shows up. I don't know about theweinreport, but since I have not seen any errors related to it, I'm assuming either allweinreinstances use the same port, or whenever theuiport succeeds in auto-incrementing, theweinreport does, too.The error fails my
gulptask, even withwatchrunning. I could probably find a way tocatchit, though I believe it callsprocess.exit, which makes it much harder, and/or auto-detect the port myself, but sinceBrowserSyncalready does this, albeit in a slightly buggy way, I would rather it stay inBrowserSync, if possible.