Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When doing a dist-upgrade recently, my lighttpd-1.4.19 install on Ubuntu 8.0.4 has begun failing to restart or reload properly with the /etc/init.d/lighttpd restart command.

~$ sudo /etc/init.d/lighttpd restart
 * Stopping web server lighttpd
 * Starting web server lighttpd
2009-06-13 04:06:36: (network.c.300) can't bind to port:  80 Address already in use!

The same error occurs when I do a reload.

The way I get around it is to kill lighttpd and then issue the start command, but it seems like I shouldn't have to do that :)

I've looked at my config files, and can't spot any immediate errors. Does anyone have any ideas what can be causing this error? This seems to be the latest version as of writing this question that is available via the apt-get route.

My config file is:

# Debian lighttpd configuration file

############ Options you really have to take care of ####################

## modules to load
# mod_access, mod_accesslog and mod_alias are loaded by default
# all other module should only be loaded if neccesary
# - saves some time
# - saves memory

server.modules              = ( 

## a static document-root, for virtual-hosting take look at the 
## server.virtual-* options
server.document-root       = "/var/www/"

## where to send error-messages to
server.errorlog            = "/var/log/lighttpd/error.log"

fastcgi.server = (".php" => ((
  "bin-path" => "/usr/bin/php5-cgi",
  "socket" => "/tmp/php.socket"

## files to check for if .../ is requested
index-file.names           = ( "index.php", "index.html",
                               "index.htm", "default.htm",
                               "index.lighttpd.html" )

## Use the "Content-Type" extended attribute to obtain mime type if possible
# mimetype.use-xattr = "enable"

#### accesslog module
accesslog.filename         = "/var/log/lighttpd/access.log"

## deny access the file-extensions
# ~    is for backupfiles from vi, emacs, joe, ...
# .inc is often used for code includes which should in general not be part
#      of the document-root
url.access-deny            = ( "~", ".inc" )

# which extensions should not be handle via static-file transfer
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

mimetype.assign             = (
  ".pdf"          =>      "application/pdf",
  ".sig"          =>      "application/pgp-signature",
  ".spl"          =>      "application/futuresplash",
  ".class"        =>      "application/octet-stream",
  ".ps"           =>      "application/postscript",
  ".torrent"      =>      "application/x-bittorrent",
  ".dvi"          =>      "application/x-dvi",
  ".gz"           =>      "application/x-gzip",
  ".pac"          =>      "application/x-ns-proxy-autoconfig",
  ".swf"          =>      "application/x-shockwave-flash",
  ".tar.gz"       =>      "application/x-tgz",
  ".tgz"          =>      "application/x-tgz",
  ".tar"          =>      "application/x-tar",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".m3u"          =>      "audio/x-mpegurl",
  ".wma"          =>      "audio/x-ms-wma",
  ".wax"          =>      "audio/x-ms-wax",
  ".ogg"          =>      "audio/x-wav",
  ".wav"          =>      "audio/x-wav",
  ".gif"          =>      "image/gif",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".xbm"          =>      "image/x-xbitmap",
  ".xpm"          =>      "image/x-xpixmap",
  ".xwd"          =>      "image/x-xwindowdump",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".asc"          =>      "text/plain",
  ".c"            =>      "text/plain",
  ".conf"         =>      "text/plain",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
  ".rss"          =>      "application/rss+xml",
  ".mpeg"         =>      "video/mpeg",
  ".mpg"          =>      "video/mpeg",
  ".mov"          =>      "video/quicktime",
  ".qt"           =>      "video/quicktime",
  ".avi"          =>      "video/x-msvideo",
  ".asf"          =>      "video/x-ms-asf",
  ".asx"          =>      "video/x-ms-asf",
  ".wmv"          =>      "video/x-ms-wmv",
  ".bz2"          =>      "application/x-bzip",
  ".tbz"          =>      "application/x-bzip-compressed-tar",
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar"

include_shell "/usr/share/lighttpd/"

My /etc/init.d/lighttpd script is (untouched from installation):

# Provides:          lighttpd
# Required-Start:    networking
# Required-Stop:     networking
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the lighttpd web server.

DESC="web server"
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"

DAEMON_OPTS="-f /etc/lighttpd/lighttpd.conf"

test -x $DAEMON || exit 0

set -e

# be sure there is a /var/run/lighttpd, even with tmpfs
mkdir -p /var/run/lighttpd > /dev/null 2> /dev/null
chown www-data:www-data /var/run/lighttpd
chmod 0750 /var/run/lighttpd

. /lib/lsb/init-functions

case "$1" in
    log_daemon_msg "Starting $DESC" $NAME
    if ! $ENV $SSD --start --quiet\
    --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then
            log_end_msg 1
            log_end_msg 0
    log_daemon_msg "Stopping $DESC" $NAME
    if $SSD --quiet --stop --oknodo --retry 30\
    --pidfile $PIDFILE --exec $DAEMON; then
        rm -f $PIDFILE
        log_end_msg 0
        log_end_msg 1
    log_daemon_msg "Reloading $DESC configuration" $NAME
    if $SSD --stop --signal 2 --oknodo --retry 30\
    --quiet --pidfile $PIDFILE --exec $DAEMON; then
        if $ENV $SSD --start --quiet  \
    	--pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then
    	log_end_msg 0
    	log_end_msg 1
        log_end_msg 1
    $0 stop
    [ -r  $PIDFILE ] && while pidof lighttpd |\
    	 grep -q `cat $PIDFILE 2>/dev/null` 2>/dev/null ; do sleep 1; done
    $0 start
    echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
    exit 1

exit 0
share|improve this question
up vote 5 down vote accepted

It sounds like your "stop" script isn't actually stopping the server cleanly.

Can you post your /etc/init.d/lighttpd file?

share|improve this answer
Thanks for the comment. I've added my config file. – NilObject Jun 13 '09 at 4:52
I was hoping to see the init script /etc/init.d/lighttpd because it contains the commands used to stop the service which may not be doing the job. – Kevin Kuphal Jun 13 '09 at 5:04
Sorry, it's getting late. That's been added too :) – NilObject Jun 13 '09 at 5:20
Thanks. It looks to me like you need to add a entry to your config file that points to the same location that the init script is looking for the PID file (/var/run/ – Kevin Kuphal Jun 13 '09 at 5:23
That was exactly it. Thank you very much for your help! – NilObject Jun 13 '09 at 5:59

Ok, sometime, when you install php5-mysql or php5-gd, it install automaticly apache2 (cause of the package dependence of Debian)

Try a top to see if apache isn't launch.

If it is installed : try a "apt-get remove apache2*"

It should be ok after

(Sorry for my bad english)

share|improve this answer

after an apt-get upgrade, I was experiencing this problem. looking at my strace output, the first bind to port 80 was successful. then when attempting an ipv6 bind to the same port, it failed. so I commented out the line:

#include_shell "/usr/share/lighttpd/"

and now it's working again.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.