HowTo: Magic Mirror – Setting up the autostart

“Out-of-theBox” the installed MagicMirror software does not start automatically after the RaspberryPi has started up. That’s why it is usefull to setup an autostart.

How to do this is described in the following article.

Hints for our lovely english readers: Basically, many of the articles on are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section. 
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂

Safety instructions

I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance.

Affiliate links / advertising links

The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support in being able to offer further useful projects in the future. 🙂


Helpful Articles:
Before you start with this article, you should have prepared the RaspberryPi so that it can be reached via the network and controlled by SSH. In addition, the MagicMirror software should already be installed.

The following articles describe what to do to prepare the RaspberryPi:
RaspberryPi – Setting up for Nerdiys!
RaspberryPi – The first configuration
RaspberryPi – Controlling the RaspberryPi via SSH

MagicMirror – Installing the required software

Required tools:

Required material:

In the following list you will find all the parts you need to implement this article.

Log in via SSH on the RaspberryPi

To get started, you first need to log in to RasPi with SSH on Putty. How to do it is described in the article

After entering your username and password you can start to enter the first commands.

Setting up the autostart with the Node.js Process Manager

There are several ways to organize the startup of the MagicMirror software. One of these ways is the ProcessManager for Node.js applications. The advantage of this is that it not only takes over the autostart of MagicMirror software. It also monitors after starting whether the software runs correctly and restarts it if necessary.

Installation of the Process Manager

Process Manager is not preinstalled on most systems. That’s why it needs to be installed with the following command.

sudo npm install -g pm2

Installation of the ProcessManager

Startup of the ProcessManager

If the ProcessManager is installed you now have to set up an autostart for the ProcessManager. Because the ProcessManager can of course only take care of the startup of the MagicMirror software, if it was previously started by itself. You can start the Autostart of the Processmanager with the following command.

sudo pm2 startup
To set up the startup of the ProcessManager you have to enter the command “sudo pm2 startup”.

Set up MagicMirror Start Script

In order for the start of the MagicMirror to work, you must first set up a startup script. To do this you change to your home directory with the following command:

cd ~

There you create a new (still empty) file:


And insert the following text in it.

cd ~/MagicMirror
DISPLAY=:0 npm start
After inserting the text you save the file by pressing “CTRL + X” and …
… a press on “Enter”.

Then you have to make this script executable. The following command suffices for this

sudo chmod +x
This gives the script the necessary rights to execute.

Now you can start the script with the ProcessManager.

pm2 start

And now comes the real magic. The following command saves the current state (The script/MagicMirror is running). This means that the ProcessManager now continuously checks whether the script is running and that the MagicMirror is running correctly. If this crashes or does not run yet, it will be automatically started by the ProcessManager.

pm2 save

Controlling the MagicMirror via the Process Manager

You can then control the MagicMirror via the ProcessManager. So start and stop. You also have the option to display log information.


pm2 restart mm


pm2 stop mm

Show logfile

pm2 logs mm

Show process information

pm2 show mm

Additional information

Have fun with the project

I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂

P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂

Buy Me a Coffee at   


  1. Guten Abend,
    vielen Dank für diese ausführlichen und gut nachvollziehbaren Erklärungen. Mein Sohn (12 Jahre) und ich versuchen die Autostartfunktion eingerichtet zu bekommen. Wir können den gesamten Weg exakt nachvollziehen, es kommen auch bis zum Eintrag “pm2 save” die Informationen in der Kommandozeile. Auch die MagicMirror Anzeige auf dem Display wird angezeigt bzw. gestartet. Leider ist es dann so, wenn ich den Strom vom Raspi4 ausschalte und wieder einschalte startet der raspi nur bis zum normalen desktop, nicht jedoch die MagicMirror Umgebung wie ich es erwarten würde. Wir verwenden die Umgebung MagicMirror2.
    Gibt es noch irgendetwas zu beachten das es beim Einschalten des Stroms dann klappt, dass die MagicMirror Umgebung gestartet wird? Mein Sohn und ich wären über eine Rückmeldung so unendlich dankbar. Gerne auch gegen eine kleine Spende. Viele Grüße aus Niedersachsen, Andreas Graupner

    1. Hey Andreas 🙂
      kannst du bitte mal folgendes ausprobieren:
      – den Befehl “pm2 startup” eingeben
      – den Befehl “pm2 start” eingeben
      – warten bis die Oberfläche des MagicMirror auf dem Bildschirm sichtbar und komplett geladen ist
      – den Befehl “pm2 save” eingeben
      – dann den RaspberryPi durch “sudo reboot” neu starten

      Falls der MagicMirror nach dem Neustart nicht automatisch gestartet wird kannst du mal gucken ob dir in den log Files etwas auffällt. 🙂 Dazu musst du den Befehl “pm2 logs mm” eingeben. Du kannst die Ausgabe davon auch gerne hier posten. Dann gucke ich mir das mal an. 🙂

      Beste Grüße

      P.S. Natürlich freue ich mich über eine Spende, aber ich helfe Euch auch so gerne. 🙂

  2. Ich weiß nicht ob gelöst…
    Ich hatte das gleiche Problem. Es lag am Ende am Autostart des ProcessManagers. Der war nicht korrekt eingerichtet. “sudo pm2 startup” war bei mir nicht ausreichend. Mir wurde nachdem ich “pm2 startup” eingegeben habe noch ein Befehl angezeigt, den ich einmal ausführen musste.

    ließ sich bei mir per ” sudo pm2 startup” nicht einrichten. Mir wurde nach “pm2 startup” ein Befehl in der Kommandozeile angezeigt, den ich ausführen musste. Jetzt funktioniert der ProcessManager korrekt inklusive Boot des MagicMirrors.

  3. Ich weiß nicht ob, ob das Problem schon gelöst wurde. Bei mir war der Autostart des ProcessManagers nicht richtig “eingerichtet”. Ich musste statt “sudo pm2 startup” “pm2 startup” eingeben. Anschließend wurde mir in der Konsole ein Befehl angezeigt, den ich ausgeführt habe. Jetzt funktioniert der ProcessManager korrekt, inklusive Boot des MagicMirrors.

Leave a Reply

Your email address will not be published. Required fields are marked *