Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(ubuntu) nginx: [emerg] bind() to 0.0.0.0:80 failed (13: permission denied)

Tags:

nginx

bind

I need help figuring out the root cause of this permission denied error. What permissions does nginx need? Why is it so complicated?

like image 859
user2350858 Avatar asked Aug 28 '13 05:08

user2350858


3 Answers

the socket API bind() to a port less than 1024, such as 80 as your title mentioned, need root access.

here is "Bind to ports less than 1024 without root access"

and another easier way is to run nginx as root.

like image 154
vvy Avatar answered Oct 21 '22 17:10

vvy


If you use a port bigger than 1024 with root privilege, but still got this problem, that's may be caused by SELinux:

Check this port, say 8024, in segange port

sudo semanage port -l | grep http_port_t

If 8024 doesn't exist in the port list, add it into segange port

sudo semanage port -a -t http_port_t  -p tcp 8024

###update in 2017.12.22

Sometimes your SELinux is disabled, you need to enforcing it first. Check the status of SELinux by

$ sestatus

More steps can read this wonderful article: https://www.digitalocean.com/community/tutorials/an-introduction-to-selinux-on-centos-7-part-1-basic-concepts

like image 14
Belter Avatar answered Oct 21 '22 19:10

Belter


If see this msg after run "nginx -t", you dont have premission run as root "sudo nginx -t"

like image 2
Koudi Avatar answered Oct 21 '22 17:10

Koudi