File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,9 @@ Thanks to: @dathbe.
1717
1818### Added
1919
20- - Added configuration option for ` User-Agent ` , used by calendar & news module (#3255 )
21- - [ linter] Added prettier plugin for nunjuck templates (#3887 )
20+ - Add configuration option for ` User-Agent ` , used by calendar & news module (#3255 )
21+ - [ linter] Add prettier plugin for nunjuck templates (#3887 )
22+ - [ core] Add clear log for occupied port at startup (#3890 )
2223
2324### Changed
2425
Original file line number Diff line number Diff line change @@ -55,6 +55,29 @@ function Server (config) {
5555 } ) ;
5656
5757 Log . log ( `Starting server on port ${ port } ... ` ) ;
58+
59+ // Add explicit error handling BEFORE calling listen so we can give user-friendly feedback
60+ server . once ( "error" , ( err ) => {
61+ if ( err && err . code === "EADDRINUSE" ) {
62+ const bindAddr = config . address || "localhost" ;
63+ const portInUseMessage = [
64+ "" ,
65+ "────────────────────────────────────────────────────────────────" ,
66+ ` PORT IN USE: ${ bindAddr } :${ port } ` ,
67+ "" ,
68+ " Another process (most likely another MagicMirror instance)" ,
69+ " is already using this port." ,
70+ "" ,
71+ " Stop the other process (free the port) or use a different port." ,
72+ "────────────────────────────────────────────────────────────────"
73+ ] . join ( "\n" ) ;
74+ Log . error ( portInUseMessage ) ;
75+ return ;
76+ }
77+
78+ Log . error ( "Failed to start server:" , err ) ;
79+ } ) ;
80+
5881 server . listen ( port , config . address || "localhost" ) ;
5982
6083 if ( config . ipWhitelist instanceof Array && config . ipWhitelist . length === 0 ) {
You can’t perform that action at this time.
0 commit comments