I installed nginx-extras in order to use lua module. I use mongroup to group and start services on my machine.

When I run nginx with this command:

    exec nginx -c "$(pwd)/nginx.conf" -g "daemon off;"

I get:

    2015/08/21 12:20:03 [debug] 24217#0: bind() #5
    2015/08/21 12:20:03 [emerg] 24217#0: bind() to failed(13:    Permission denied)

I have seen some post where it says that I have to launch nginx as root user because only root user can use port 80. So I added:

    user root;

to my nginx.conf. After this, nothing change and I still get this issue.

  • 1
    Could you edit the output of getenforce into your question? Which user as you running the exec nginx command as? Becoming root means more than just asking for it in a config file.
    – MadHatter
    Aug 21, 2015 at 12:44
  • Doesn't nginx come with an init script such that it can be started through a more standardized method than this hack?
    – kasperd
    Aug 21, 2015 at 16:05

1 Answer 1


You cannot open privileged ports (<=1024) as non-root. Telling nginx to run as root is nice, but it can't switch to root from a normal user itself. You could run it inside sudo to start it as root. It would be a bad idea to run it as root forever so you should put a non-privileged user in there so nginx can run without making your machine easier to attack.

  • 1
    Uset setcap for following capabilities: cap_net_bind_service+eip
    – Navern
    Aug 21, 2015 at 13:43
  • 'You cannot open privileged ports (<=1024) as non-root.' Is that prohibited by the OS or by Nginx? Aug 21, 2015 at 16:23
  • the OS enforces it. see unix.stackexchange.com/questions/10735/…
    – chicks
    Aug 21, 2015 at 18:24

Not the answer you're looking for? Browse other questions tagged .