MagicMirror² v2.4.1 is available! For more information about this release, check out this topic.
Please read the release notes carefully since this update requires adjustments to your Raspberry Pi configuration!

Shutting down/restarting via PM2 not closing server

  • I’m using PM2 to monitor the MagicMirror2 process as per the Autostarting Magic Mirror tutorial. When I make a change and wish to restart the mirror process, I enter pm2 restart mm and let PM2 do its thing. However, when I do so I get the following error:

    Whoops! There was an uncaught exception...
    0|mm       | { Error: listen EADDRINUSE 
    0|mm       |     at Object.exports._errnoException (util.js:1022:11)
    0|mm       |     at exports._exceptionWithHostPort (util.js:1045:20)
    0|mm       |     at Server._listen2 (net.js:1262:14)
    0|mm       |     at listen (net.js:1298:10)
    0|mm       |     at Server.listen (net.js:1376:9)
    0|mm       |     at new Server (/home/pi/MagicMirror/js/server.js:26:9)
    0|mm       |     at /home/pi/MagicMirror/js/app.js:219:18
    0|mm       |     at loadNextModule (/home/pi/MagicMirror/js/app.js:168:5)
    0|mm       |     at /home/pi/MagicMirror/js/app.js:163:6
    0|mm       |     at Class.loaded (/home/pi/MagicMirror/modules/node_modules/node_helper/index.js:19:3)
    0|mm       |   code: 'EADDRINUSE',
    0|mm       |   errno: 'EADDRINUSE',
    0|mm       |   syscall: 'listen',
    0|mm       |   address: '::',
    0|mm       |   port: 8080 }

    This normally occurs when you have MM2 running and attempt to start the mirror again. But that’s not the case as far as I can tell. If I use PM2 to stop the MM2 process, netstat -l doesn’t show anything listening on port 8080, but I still get the error above if I start the mirror process.

    This only started after I upgraded to v2.1.2, if that helps. A full reboot will have the mirror start normally. Any ideas?

  • Update: I’ve traced this to the MMM-RTSPStream module. Disabling this module lets PM2 restart the process normally. I’ll take this problem over there. Feel free to close this out.