rontoDay rontoDay - 1 year ago 151
Linux Question

linux systemd service on port 80

I try to create systemd service on centos7:

Description=Node.js Weeki Server

ExecStart=/usr/bin/node /var/node/myapp/bin/www
StandardOutput=syslog # Output to syslog
StandardError=syslog # Output to syslog
Environment=NODE_ENV=production PORT=80


When i use port 8080 the service start successfully, but when i change the port to 80, the service failed to start.
I try to open the firewall with the command:

firewall-cmd --zone=public --add-port=80/tcp --permanent

But it still not working.

rsp rsp
Answer Source

See the good advises that you got in the comments by arkascha.

First of all - what's the error?

What you can do to test if it's a problem of the user not being able to bind to low ports is trying use ports like 81, 82, 83 etc. If you still cannot bind to those ports then you likely don't have the permission. If you can, then it's not about permissions and the port is already used by some other process.

To see if you can open a given port by that user try running netcat:

nc -l 80

where 80 is the port number. Try low ports like 80, 81, 82 and high ports like 8080, 8081, 8082.

To see if anything is listening to that port try running:

curl http://localhost:80/


nc localhost 80

To see open ports on your system run:

netstat -lnt

To see if other instances of your program are running, try:

ps aux | grep node
ps aux | grep npm
ps aux | grep server.js

If all else fails, you can restart and see if the problem remains:

sudo shutdown -r now

That should give you a clean state with no old processes hanging around.

But you need to at least try to follow the advice that you were given. You cannot expect to get any answers to your questions if you keep ignoring both the advises posted in the comments by arkascha and other answers to your questions like the one I gave you before.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download