Auto Start Node server on Boot
Posted: Wed Mar 29, 2023 9:50 pm
Hi,
I'm currently struggling with auto-starting a node server on boot.
I aim for the device to host a node server and auto-start it by running node server.js command on every boot.
Currently, i have a service file here: /etc/systemd/system/node.service
=== node.service ===
[Unit]
Description=My Node.js App
[Service]
ExecStart=/usr/bin/node /path/to/your/app.js
Restart=always
User=mha
Group=root
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
I have reloaded daemons and enabled the service with
`sudo systemctl enable node.service`
And the log shows that
`Serving at port 3000`
But whenever i try to access 10.0.0.1:3000, it shows:
`Cannot get /`
Any help would be appreciated.
Thank you so much!
I'm currently struggling with auto-starting a node server on boot.
I aim for the device to host a node server and auto-start it by running node server.js command on every boot.
Currently, i have a service file here: /etc/systemd/system/node.service
=== node.service ===
[Unit]
Description=My Node.js App
[Service]
ExecStart=/usr/bin/node /path/to/your/app.js
Restart=always
User=mha
Group=root
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
I have reloaded daemons and enabled the service with
`sudo systemctl enable node.service`
And the log shows that
`Serving at port 3000`
But whenever i try to access 10.0.0.1:3000, it shows:
`Cannot get /`
Any help would be appreciated.
Thank you so much!