Reputation: 3
I would like to use Port 502 for my ModBus Server Flow, however, I can only do this if I run "sudo node-red-start"
I have it set to run as a service using "sudo systemctl enable nodered.service" However, this only seems to execute it as a normal user.
Thanks
Upvotes: 0
Views: 1264
Reputation: 59628
There is another way to the one @knolleary has suggested, which is to allow the pi user to open low ports. This can be done by running the following command:
sudo setcap 'cap_net_bind_service=+ep' `which node`
This will allow the node binary bind to ports lower than 1024 as any user.
Be aware that this could be a security issue as it will allow any user to run NodeJS app that can then pretend to be a system service (e.g. SSH)
Upvotes: 0
Reputation: 10117
Running systemctl
with sudo
has no bearing on what user the resulting service is run as. That is defined in the service file.
You need to edit nodered.service
file and update the User
and Group
settings.
...
[Service]
Type=simple
# Run as normal pi user - feel free to change...
User=pi
Group=pi
WorkingDirectory=/home/pi
...
That file should be located in /lib/systemd/system/nodered.service
.
Upvotes: 1