Lighttpd daemon is failed

Expected Behaviour:

lighttpd daemon is active

Actual Behaviour:

lighttpd daemon is failed

Debug Token:

https://tricorder.pi-hole.net/q2sahsgx41

Additional information

I know this isn't a unique question as I've read quite a few topics on this forum while trying to get this figured out for myself. But from what I've read and tried, nothing is helping, I even tried to install that gamin, (I think that's what it's called) since that was a work around for this problem at one point. I'm an absolute amateur when it comes to anything Linux or anything Linux related.
While trying to start or run lighttpd manually I get this for an output

lighttpd -D -f /etc/lighttpd/lighttpd.conf
2019-10-11 10:47:34: (configfile.c.1599) server.upload-dirs doesn't exist: /var/cache/lighttpd/uploads
2019-10-11 10:47:34: (server.c.1209) opening pid-file failed: /var/run/lighttpd.pid Permission denied
2019-10-11 10:47:34: (server.c.428) unlink failed for: /var/run/lighttpd.pid 2 No such file or directory

but if I sudo that very same command command, I get this for an output. At first I was thinking that directory permissions might be the problem, I read somewhere that lighttpd uses www-data as the user, but when I did a chown and changed the /var/cache/lighttpd directory to pi, while I got rid of the server.upload-dirs doesn't exist message by doing so, it was still giving the the error about not finding the lighttpd.pid as not being found, which makes complete sense since that file doesn't exist in my /run/ directory.

sudo lighttpd -D -f /etc/lighttpd/lighttpd.conf
2019-10-11 10:51:46: (network.c.309) can't bind to socket: 0.0.0.0:80 Address already in use

Alright, that seems easy enough, but for whatever reason, I am just drawing a total and complete blank on how to fix this. I've tried to do multiple installs of Pi-hole on my Raspberry Pi 4 running Buster, and I always run into the same problems.

sudo netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:4711          0.0.0.0:*               LISTEN      1075/pihole-FTL
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      678/mysqld
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      1069/smbd
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      1075/pihole-FTL
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      587/sshd
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      1069/smbd
tcp6       0      0 ::1:4711                :::*                    LISTEN      1075/pihole-FTL
tcp6       0      0 :::139                  :::*                    LISTEN      1069/smbd
tcp6       0      0 :::80                   :::*                    LISTEN      649/apache2
tcp6       0      0 :::53                   :::*                    LISTEN      1075/pihole-FTL
tcp6       0      0 :::22                   :::*                    LISTEN      587/sshd
tcp6       0      0 :::445                  :::*                    LISTEN      1069/smbd
udp        0      0 0.0.0.0:53              0.0.0.0:*                           1075/pihole-FTL
udp        0      0 0.0.0.0:68              0.0.0.0:*                           481/dhcpcd
udp        0      0 192.168.0.255:137       0.0.0.0:*                           539/nmbd
udp        0      0 192.168.0.111:137       0.0.0.0:*                           539/nmbd
udp        0      0 0.0.0.0:137             0.0.0.0:*                           539/nmbd
udp        0      0 192.168.0.255:138       0.0.0.0:*                           539/nmbd
udp        0      0 192.168.0.111:138       0.0.0.0:*                           539/nmbd
udp        0      0 0.0.0.0:138             0.0.0.0:*                           539/nmbd
udp        0      0 0.0.0.0:3763            0.0.0.0:*                           517/openvpn
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           401/avahi-daemon: r
udp        0      0 0.0.0.0:38145           0.0.0.0:*                           401/avahi-daemon: r
udp6       0      0 :::59908                :::*                                401/avahi-daemon: r
udp6       0      0 :::546                  :::*                                481/dhcpcd
udp6       0      0 :::53                   :::*                                1075/pihole-FTL
udp6       0      0 :::5353                 :::*                                401/avahi-daemon: r

Apache is already taking port 80, so would I just have to change the port Pi-Hole uses? I read on someone's post that they did that, but then they got shamed for whatever reason and how that effects Pi-Holes performance with certain blocking aspects. Or maybe I'll have to try and change Apache's port and setup port forwarding... I'm just at my wits end, as I previously stated, Linux and me aren't friends. Any help would be greatly appreciated

You don't change the port that Pi-Hole uses (the various parts of Pi-Hole use several ports). You can change the port that lighttpd (the software used by Pi-Hole for the web admin and block pages) uses.

The port is specified in etc/lighttpd/lighttpd.conf

After you make the change, you will have to restart lighttpd. Also note that when you upgrade or repair Pi-Hole, your local port change will be overwritten, so you will need to make the change again.

Thank you for your response, and making me feel like a fool :rofl:. I have read about making that change and that it'll be overwritten upon upgrade or repairs. In the back of my mind, I was thinking that if we have to make the change every single there's an upgrade, then this just must be a temporary fix, there must be something more permanent. Is there any plans to make the port used by lighttpd user defined through the Pi-Hole interface since the change will get overwritten by every update?

Since there's going to be problems with making these changes stick, I run a nightly backup script via cron, I just added this to the head of my backup script.

#!/bin/bash
service lighttpd stop
sed -i.bak 's/80/8034/1' /etc/lighttpd/lighttpd.conf
service lighttpd start

Doing it this way, shouldn't cause any additional problems, will it?

I don't think it will.

There is an open feature request for this:

Since you're new to Linux, I thought I'd give you a couple of troubleshooting pointers. First, when you see a permissions error on a file that isn't in your home directory (/home/pi by default on Raspbian), it normally means one of two things:

  1. Make sure that you're really doing what you thing you're doing, because you might be inadvertantly messing with system settings.
  2. You need to be root to do this. Put sudo in front of the command. But: a) see number 1 first, and b) only use sudo when you actually need it. If you're unsure, try the command first without sudo.

What you shouldn't do: You shouldn't change file permissions unless you know exactly what you're doing, particularly if the files in question aren't in your home directory. Setting permissions incorrectly can badly break your system and force you to reinstall the operating system. Since you installed the software using an installer, you can be confident that the permissions are already correct.

Now we come to this line. The error is "Permission denied." In almost every case, this error means that you need to be root to perform whatever operation is described. In this case, lightppd tried to write a PID file. This is a common way on Linux for daemons to keep track of their instances. (A Linux daemon is somewhat like a Windows service.) It expected to write that file in a well-known location that is only writable by root. When that failed, it printed the error message I quoted and began its shutdown routine. Part of that routine is to delete (unlink) the PID file. That also failed due to not being root.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.