[SOLVED] Error "(network.c.307) can't bind to socket: 0.0.0.0:8082 Permission denied" when starting Lighttpd as a systemd service
Added by anstri over 5 years ago
I´m on RHEL 7, Lighttpd 1.4.54.
When running the following command as root from command prompt, everything works:
/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
When trying to start the same command as a systemd service, it fails with the following error:
(network.c.307) can't bind to socket: 0.0.0.0:8082 Permission denied
lighttpd.conf:
server.document-root = "/dir1/lighttpd/lighttpdDocRoot/"
server.port = 8082
server.username = "root"
server.groupname = "root"
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".jpg" => "image/jpeg",
".png" => "image/png"
)
server.modules = ("mod_setenv", "mod_proxy", "mod_rewrite")
$SERVER["socket"] == ":8082" {
proxy.server = ( "" => ( "myhost.lmvs.lm.se:8081" => ("host" => "myhost.lmvs.lm.se", "port" => 8081)) )
url.rewrite-once = ("^/(.*)" => "/$1")
}
lighttpd.service file:
[Unit]
Description=Lighttpd web server
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
[Install]
WantedBy=multi-user.target
Can anyone of you point out what might be wrong?
Thank´s in advance!
Replies (3)
RE: Error "(network.c.307) can't bind to socket: 0.0.0.0:8082 Permission denied" when starting Lighttpd as a systemd service - Added by gstrauss over 5 years ago
Have you tried asking the search engine you use every day?
https://superuser.com/questions/1046870/lighttpd-cant-bind-to-port-permission-denied
RE: Error "(network.c.307) can't bind to socket: 0.0.0.0:8082 Permission denied" when starting Lighttpd as a systemd service - Added by anstri over 5 years ago
Unfortunately yes. Alsto tried with ports 8083, 8084.
Issuing netstat -tulpn
gives the following result:
tcp 0 0 0.0.0.0:11001 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN
tcp 51 0 0.0.0.0:11002 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:11100 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:44093 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:44446 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9092 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:39270 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9001 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:57709 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8400 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
tcp 0 0 143.237.8.150:8081 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:51666 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8403 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:53046 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp6 0 0 :::33581 :::* LISTEN
tcp6 0 0 :::53 :::* LISTEN
udp 0 0 0.0.0.0:53 0.0.0.0:*
udp 0 0 0.0.0.0:111 0.0.0.0:*
udp 0 0 127.0.0.1:323 0.0.0.0:*
udp6 0 0 :::53 :::*
udp6 0 0 ::1:323 :::*
[SOLVED]: Error "(network.c.307) can't bind to socket: 0.0.0.0:8082 Permission denied" when starting Lighttpd as a systemd service - Added by anstri over 5 years ago
It turned out that ports 8082-8084 was reserved/used but it did not show with netstat -tulpn
command.
I used semanage instead to see if port was reserved: semanage port -l | grep 8082
It gave the following result:
us_cli_port_t tcp 8082, 8083
us_cli_port_t udp 8082, 8083
Solved it by using port 8011 instead:
- Find a free port (in my case 8011):
semanage port -l | grep 8011
- Add port 8011 and allow http on it:
semanage port -a -t http_port_t -p tcp 8011
- Change my lighttpd.conf to use port 8011 instead:
server.document-root = "/dir1/lighttpd/lighttpdDocRoot/" server.port = 8011 server.username = "root" server.groupname = "root" mimetype.assign = ( ".html" => "text/html", ".txt" => "text/plain", ".jpg" => "image/jpeg", ".png" => "image/png" ) server.modules = ("mod_setenv", "mod_proxy", "mod_rewrite") $SERVER["socket"] == ":8011" { proxy.server = ( "" => ( "myhost.lmvs.lm.se:8081" => ("host" => "myhost.lmvs.lm.se", "port" => 8081)) ) url.rewrite-once = ("^/(.*)" => "/$1") }
Now everything works! :-D