"lpc: connect: No such file or directory couldn't start daemon" error in lpd

If you run BSD lpr, sooner or later you will experience the mysterious lpd connect problem. Jobs pile up in the queue, but restarting the printer (lpc restart myprinter) gives the following error:

   lpc: connect: No such file or directory
        couldn't start daemon

Under these conditions, is is still possible to telnet to the printer on port 9100 and print jobs manually. Lpd is still running. Normally, there should be two lpds while a job is printing, and only one otherwise. However, when this bug hits, there are always two.

This is a problem with a socket connection between lpd and the printer. "connect" is an OS function, not a program. No one knows why the second lpd daemon suddenly starts hanging.

Usually, it can be restarted. The following are arranged in order from most to least likely to have an effect. In most cases, the first four will fix the problem.

  1. Make sure lpd is in fact running.
  2. Remove any lock files in /var/spool/lpd and restart lpd in /etc/init.d.
  3. Ping the printer to make sure it's still on the network. Power-cycle every network component between the printer and the server.
  4. Power-cycle the printer. Sometimes the network port of a printer gets screwed up because of random network traffic or weird packets from outside.
  5. Stop lpd, wait a few seconds, and restart it; or reboot. The port may be hanging for some reason.
  6. The behavior of lpd can be checked with strace:
       pidof lpd  
       strace -f -p 1758 2>&1 
    Check for incorrect IP addresses, inaccessible files, etc.
  7. Remove any lock files in /var/spool/myprinter. Lpd is supposed to delete these automatically, but may not.
  8. Check permissions in /var/spool, and make sure lpd and lpc look like the following:
          -rwxr--r--    1 root     root        50568 Jan 19  2001 /usr/sbin/lpd
          -r-sr-sr-x    1 root     lp          24764 Jan 19  2001 /usr/sbin/lpc
          -r-sr-sr-x    1 root     lp          15432 Jan 19  2001 /usr/bin/lpq
       ls -l /var/spool
          drwxr-xr-x   13 lp       lp           4096 Feb  3  2003 lpd
       ls -l /var/spool/lpd
          drwxrwxrwx    2 root     root          253 Dec  8 08:52 hpbw
       ls -l /var/spool/lpd/hpbw
          -rwxrwxrwx    1 root     root            0 May 20  2002 control.hpbw
          -rw-rw-rw-    1 root     root            0 May 20  2002 errs
          -rwxrwxrwx    1 root     root         9479 May 20  2002 filter
          -rw-rw-rw-    1 root     root           18 Dec  8 08:52 lock
          -rw-rw-rw-    1 root     root           26 Dec  8 08:52 status
       cat status
       sending to
  9. Check for errors in /etc/printcap.
  10. Reinstall lpd or upgrade to lprng.
  11. Throw computer out the window, or shoot it with an AK-47 assault rifle, and then quit your job and become a monk (do this only as a last resort).