cups — fixing cups printer problem: lpd failed 

Introduction

Recently, our HP2420dn printer stopped working. Well, it was not really the printer… printing jobs went but nothing came out of the printer. The cups server has put the printer into a stopped state with the StateMessage /usr/lib/cups/backend/lpd failed. What caused this? Well, I am not really sure, however the cups server error logs (http://localhost:631/admin/log/error_log, or alternatively /var/log/cups/error_log) tell at least part of the story, as shown below.

...
I [22/Sep/2007:12:36:40] Adding start banner page "none" to job 835.
I [22/Sep/2007:12:36:40] Adding end banner page "none" to job 835.
I [22/Sep/2007:12:36:40] Job 835 queued on "printer" by "kamil".
I [22/Sep/2007:12:36:40] Started filter /usr/lib/cups/filter/pstops (PID 2607) for job 835.
I [22/Sep/2007:12:36:40] Started backend /usr/lib/cups/backend/lpd (PID 2608) for job 835.
I [22/Sep/2007:12:37:53] Adding start banner page "none" to job 836.
I [22/Sep/2007:12:37:53] Adding end banner page "none" to job 836.
I [22/Sep/2007:12:37:53] Job 836 queued on "printer" by "kamil".
...
W [22/Sep/2007:12:41:41] [Job 835] Remote host did not respond with command status byte after
300 seconds!
E [22/Sep/2007:12:41:45] PID 2608 (/usr/lib/cups/backend/lpd) stopped with status 1!
I [22/Sep/2007:12:41:45] Hint: Try setting the LogLevel to "debug" to find out more.
I [22/Sep/2007:12:41:45] [Job 835] Backend returned status 1 (failed)
I [22/Sep/2007:12:41:45] Saving printers.conf…
…

From the above error log fragments, it can be seen that the communication with the HP printer timed out, causing the lpd to exit with an error status. Now, because of this error, the cups server has stopped the printer. Later on I'll show you how to alter this default cups behaviour. Now, lets take a quick look at the printer queue status using the following command.

lpq

The printer is listed as not ready as is shown in the output below.

printer is not ready
no entries

Interestingly, this error happend on a few workstations around the same time. Anyhow, there are number of ways to fix such a problem. One could remove the printer and then install it again. That fixes it, but there are simpler ways. One could use some sort of front end to cups configuration, such as its web interface (i.e. http://localhost:631/), to start the printer again. Or, one could edit cups config files directly, solution courtesy of Mr Brett Wildermoth. This is how I got our printer working again.

Fixing the problem
First, to verify that you are experiencing the same kind of problem as I did, run:

sudo cat /etc/cups/printers.conf # ©2007 dsplabs.com.au

This should show you a list of installed printers with their settings and status, as show below.

# Printer configuration file for CUPS v1.2.10
# Written by cupsd on 2007-09-22 12:41

<printer>
Info HP2420dn
Location SPL
DeviceURI lpd://123.234.103.10/printer
State Stopped
StateMessage /usr/lib/cups/backend/lpd failed
StateTime 1190428905
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</printer>

<defaultprinter>
Info richo afico 3030
Location outside spl
DeviceURI socket://123.234.102.11:9100
State Idle
StateTime 1183439409
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</defaultprinter>

The above config file shows that there are two printers installed under cups with the following device URIs lpd://123.234.103.10/printer and socket://123.234.102.11:9100. The first printer (HP2420dn) is in a stopped state due to a lpd error. To fix the problem you'll have to replace the follwing two lines in the /etc/cups/printers.conf file:

State Stopped
StateMessage /usr/lib/cups/backend/lpd failed

with this line:

State Idle

To achieve the above you could use your favourite text editor, or the following sed on-liner.

sudo sed -i -e '/StateMessage .*lpd failed/d' -e 's/State Stopped/State Idle/' /etc/cups/printers.conf

Have another look at the output of:

sudo cat /etc/cups/printers.conf # ©2007 dsplabs.com.au

to double check that fixing the error lines worked correctly. My /etc/cups/printers.conf file now look as follows.

# Printer configuration file for CUPS v1.2.10
# Written by cupsd on 2007-09-22 12:43

<printer>
Info HP2420dn
Location SPL
DeviceURI lpd://123.234.103.10/printer
State Idle
StateTime 1190428905
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</printer>

<defaultprinter>
Info richo afico 3030
Location outside spl
DeviceURI socket://123.234.102.11:9100
State Idle
StateTime 1183439409
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
</defaultprinter>

Then the final step is to restart the cups server using:

service cups restart

or alternatively:

/etc/init.d/cups restart

Note that on your platform cups daemon might actually be called cupsd. If so, you'll have to change the above commands accordingly to reflect this difference. Now, looking at the printer queue status once more (using the lpq command) we see that the problem is fixed.

printer is ready
no entries

You may have noticed that there is an entry in the /etc/cups/printers.conf file called ErrorPolicy set to stop-printer. This could be changed so that the printer does not get stopped on an error. The other possible settings are abort-job and retry-job. You could use the following sed one-liner for this purpose.

sudo sed -i -e 's/ErrorPolicy stop-printer/ErrorPolicy abort-job/' /etc/cups/printers.conf

Hope this helps!


Did you find the above information useful and interesting? If so, please support this site by using the blog directory links at the bottom of this page. Thanks for your support!

If you have any Linux related problems or questions then please feel free to post them on our Linux Forums: http://linux.dsplabs.com.au/forums.




VPS Hosting Referral Code DZZCC3

Add me to Technorati Favorites Vote for me on Blog Catalog

49 Responses to “cups — fixing cups printer problem: lpd failed

  1. Godders Says:

    Worked a treat, you rock!

  2. George Hickey Says:

    Just though you might like to know - your solution is helping keep the blood supply in Ireland flowing! Nice one guys!! Cheers, G.

  3. Kamil Says:

    Greetings from Brisbane George, I am very happy this info was useful to you! :D

  4. Radhika Says:

    Hey it was a real useful solution. I was getting the error - /usr/lib/cups/backend/socket failed and it still worked. Thanks a lot. :-)

  5. Carlos Says:

    Dude, I love you!

  6. Alexander Says:

    Thank you man. Your post just save me :-)

  7. DanB Says:

    Thanks for the solution! The restart commands did not work for me in Ubuntu 7.10
    service cups restart or /etc/init.d/cups restart

    So I just fire up cups http://localhost:631/
    Went to the printer and hit restart. All fixed.

    Your instructions made it easy to fix.

  8. Gimili Says:

    50 14 * * 1,2,3,4,5 sudo sed -i -e '/StateMessage Paused/d' -e 's/State Stopped/State Idle/' /etc/cups/printers.conf
    55 14 * * 1,2,3,4,5 /etc/init.d/cups restart

    I put this in a cron job. Darn lpd printer kept getting paused. This seems to be the cure to make sure it doen't get left paused. Thanks!!!

  9. Carmen Rodriguez Says:

    Thank you very much!

    Excellent post, very esay to follow

  10. Keith Says:

    This worked perfect! Thank God for the dsplabs & the internet! (It's sudo /etc/init.d/cupsys restart in 7.10 in case someone doesn't know.)

  11. Michael Says:

    Thanks for this…
    The sudo sed -i -e 's/ErrorPolicy stop-printer/ErrorPolicy retry-job/' /etc/cups/printers.conf
    and /etc/init.d/cups restart worked a treat.

    —Redhat enterprise 5—

  12. Adam Says:

    Thanks very much to you and to Google.
    I learned something new today and the punters are happy, which is why we are here .

  13. Koen Says:

    Worked on this on and off for a couple of days. Didn't know where to start searching (Linux box or MS Windows with LPD); Google's second hit for "troubleshoot lpd" directed me to your site. This solved the problem. Thanks !

  14. Kyle Says:

    You saved me a lot of time. Thanks very much. Suse Linux 2.6.22.5-31……

  15. Jefferson Says:

    why not use cupsenable to re-enable printer??

  16. AIX Dude Says:

    I'm an AIX SysAdmin but a newcomer to SUSE Linux (SLES10). Used your two-line replacement and cups restart solution and it worked GREAT! Your article was well-written–concise and easy to understand. Thanks a bunch from a Filipino dude in sunny Southern California.

    SUSE Linux 2.6.16.60-0.21-default

  17. Jakob Cornelis Says:

    It did not work for me. CUPS seems to simply rewrite the file "printers.conf" file to what it was before, i.e.
    State Stopped
    StateMessage /usr/lib/cups/backend/lpd failed

  18. Hal Huntley Says:

    I put the error message in to google and yours was the first hit. Well written documentation. I followed the advice and it worked just fine. In our case, it was a xerox printer where one of the color's toner was out for a while and so would not print. After the toner was replaced, obviously the "new" state of the printer didn't get back to the linux box (fc9).

  19. Shashank Says:

    Why not simply enable the printer?
    /usr/bin/enable $printername works for me.

    Other option could be to increase the timeout option from the configuration file for cups.

  20. akbar Says:

    It is not work for me. CUPS seems to simply rewrite the file "printers.conf" file to what it was before, i.e.
    State Stopped
    StateMessage /usr/lib/cups/backend/lpd failed

    just after giving print from my snow leopard and going to State Idle after resuming the printer manually after deleting the queue only

  21. Kamil Says:

    Hi akbar, this could happen for many reasons. Does it happen for any file? or only when you try to print one specific file? Some odd pdf files crash our HP2420dn printer for instance. If that is the case for you, then try changing the error policy as described at the end of the post, fix the file (e.g., conver to ps and back) or simply print it on another printer.

  22. pgri Says:

    Thank you! I have never seen this problem before but the solution worked perfectly.
    RH5 2.6.18-53.el5

  23. siva Says:

    Interesting post, thanks for sharing this

  24. STE Says:

    Clean and nice instructions.
    Works well after CUPS update on Slack-13.1, restart with "/etc/rc.d/rc.cups restart" and everything runs again.
    Thanks!

  25. Ameet Says:

    you rock boss!

  26. Agamiyya Says:

    Nice! Thank you!

  27. blessedme Says:

    This worked perfectly for me . Thanks a bunch.

  28. arumon Says:

    "cupsenable" command works for me. :-)

  29. Mark E Says:

    Excellent - seems like a bit of a dodgy hack, but it worked so I'm happy. It's strange how you can't achieve the same thing in system-config-printer.

    Thanks for the tip.

  30. Abid Says:

    Thanks Buddy. I used reinstall the printer to fix the error. This worked fine. Unfortunately I couldn't find the error policy entry in the file.

  31. Rashmi Says:

    Thanks a lot! My printer problem got solved after following the steps that you have outlined. Moreover, it was fun as I understood exactly what was happening!

  32. Adelaide Printers Says:

    Hi i am searching for this problem from a long time.

  33. parveen dabas Says:

    Great. worked for me too. thanks

  34. baxy Says:

    yeap it worked , thnx

  35. WJH Says:

    Thnx,

    This is easier way to fix it that using the &*(^ cups webpage! commandline rules!

  36. David Zafra Says:

    Great post! Here's what has worked for me in Ubuntu 8.04:

    /etc/crontab
    ————————————–
    35 9 * * * root /etc/cups/start_printers.sh

    /etc/cups/start_printers.sh
    ————————————–
    sed -i -e '/StateMessage */d' -e 's/State Stopped/State Idle/' /etc/cups/printers.conf
    /etc/init.d/cupsys restart

    Thanks.

  37. Sarah Says:

    Thank you! Greetings from Cern :).

  38. Juan F Diaz Says:

    Great post!!! It fixed Linux Red Hat Enterprise 5.6 Thanks

  39. vrg Says:

    Sorry. Did not work for me.

  40. Richard H Says:

    Fixed the problem GOOD!

  41. Jamkid Says:

    Thank You this was a great fix.

  42. hpt Says:

    Thanks!

  43. Robert Leleu Says:

    I just had this error for a Canon ix6500 USB working on my LAN from a TG788VN box.
    The error was also visible in the printer properties displayed by the printer configurer.
    The erreor was visible from an idle computer on the LAN. And there was no "State Stopped
    StateMessage /usr/lib/cups/backend/lpd failed" line in /etc/cups/printers.conf .
    I deduced that the error was in the box, restarted it, and the printer resuscited.

  44. leo Says:

    Awesome….down here in Africa i say thank you…

  45. Steven Says:

    Not been able to print since I upgraded to Fedora 18. With this simple fix I can now print again! Thank you!

  46. Daniel Says:

    Thank you for this post. It not only useful but informative.

  47. shubhadip Says:

    Whenever we give prints this below error is coming

    We tried with different hplip package from different machine. When we restart cups service ,error is gone ,but again it comes when we give print.

    [root@**** ~]# lpr -P FEUS1P025 text

    [root@**** cups]# lpstat -p
    printer FEUS1P025 is idle. enabled since Thu 25 Jul 2013 02:48:05 PM CEST
    /usr/lib/cups/backend/lpd failed
    [root@**** cups]#

    from /var/log/cups:
    ————————————
    D [25/Jul/2013:14:48:05 +0200] PID 15133 (/usr/lib/cups/filter/pstoraster) exited with no errors.
    D [25/Jul/2013:14:48:05 +0200] PID 15134 (/usr/lib/cups/filter/hpcups) exited with no errors.
    D [25/Jul/2013:14:48:05 +0200] Discarding unused printer-state-changed event…
    D [25/Jul/2013:14:48:05 +0200] Discarding unused printer-state-changed event…
    D [25/Jul/2013:14:48:05 +0200] Discarding unused printer-state-changed event…
    D [25/Jul/2013:14:48:05 +0200] [Job 1] Connected to 10.54.192.25:515 (IPv4) (local port 1023)…
    D [25/Jul/2013:14:48:05 +0200] [Job 1] lpd_command 02 FEUS1P025
    D [25/Jul/2013:14:48:05 +0200] [Job 1] Sending command string (11 bytes)…
    D [25/Jul/2013:14:48:05 +0200] [Job 1] Reading command status…
    D [25/Jul/2013:14:48:05 +0200] [Job 1] lpd_command returning -1
    E [25/Jul/2013:14:48:05 +0200] PID 15135 (/usr/lib/cups/backend/lpd) stopped with status 1!
    D [25/Jul/2013:14:48:05 +0200] [Job 1] File 0 is complete.
    I [25/Jul/2013:14:48:05 +0200] [Job 1] Backend returned status 1 (failed)
    ————————————-

    Please help us

  48. B Says:

    In Australia I say thankyou … after hours of searching and futile mucking around the command: ' sudo sed -i -e '/StateMessage .*lpd failed/d' -e 's/State Stopped/State Idle/' /etc/cups/printers.conf ' greatly helped for my Canon MX430. Many many many thanks.

  49. Jack Benney Says:

    Awesome Sauce! Thanks!

Leave a Reply