Printing at home from your Raspberry Pi
Yesterday I wrote about working from home with your Raspberry Pi, and talked about things like how to connect to your company VPN, and how to get video conferencing up and working. However, one thing I didn’t talk about – and that many of you have asked for some guidance on – was printing.
To get printing up and working on your Raspberry Pi the first thing you need to do is install CUPS. CUPS is an open source printing system developed by Apple that uses the Internet Printing Protocol (IPP) to support printing to both local and network printers.
Go ahead and open a terminal window, and install CUPS.
$ sudo apt-get install cups
CUPS has a lot of dependencies, so depending on your broadband connection installation, it could take a while. If you have any left in the house, now might be a good time for a cup of coffee ☕.
After installation you’ll need to give the pi user administrative rights on CUPS. To do this, go back to your console and type
$ sudo usermod -a -G lpadmin pi
to make the pi user part of the lpadmin group.
Adding a printer
Now open up your browser and navigate to https://localhost:631 . You’ll receive a security warning from your browser. Hit the ‘Advanced’ button and then ‘Proceed to localhost (unsafe)’.
You’ll be presented with the CUPS interface. Click on ‘Administration’ in the top bar, and a drop-down will appear. Authorise yourself to CUPS as the pi user, which we’d added to the administrator group earlier.
After you authorise yourself, click on the ‘Add Printer’ button. CUPS will then look for locally connected (via USB) printers as well as any networked printers it can see on your home network.
For a lot of printers you’ll be presented with a number of possible options, as most modern printers offer a number of ways to connect. So depending on which printer you have, you might need to go through the process of adding a printer a couple of times to figure out the best method to connect.
I have a Brother HL-3140CW, an older model colour laser printer. While Brother offers Linux drivers, they are compiled for the x86 rather than ARM architecture, and the open source ‘brlaser’ driver doesn’t support my model. However, CUPS does list a ‘driverless’ option for communicating without a native printer driver using the Internet Printing Protocol (IPP).
Picking this option, I was presented with a list of drivers for the printer. I picked IPP Everywhere from the list, and hit the ‘Add Printer’ button.
After a few seconds CUPS should present you with the ‘Printers’ tab, which should show you your connected printer. If everything is okay it should show that the printer is ‘Accepting Jobs’.
Testing the printer
Now we have our printer set up we need to test it. Go ahead and open LibreOffice Writer from the start menu, and enter some test text.
Then click on ‘File > Print’ in the LibreOffice Writer menu.
If everything has gone smoothly your printer should start making appropriate printing noises and should print your test document.
I actually went ahead and printed two test documents just to be sure colour printing was working okay, and happily it was working just fine!
The exact process you’re going to go through to get your printer working will depend heavily on which printer you own. The trickiest bit is always going to be drivers. Thankfully, these days things are a lot easier than they used to be, as most printers – especially networked printers that live on your wireless network – offer standard ways to print and you don’t necessarily have to rely on a native (manufacturer-provided) driver any more.
Very nice. Thanks for the post!
Great tutorial!! Worked perfect and the explanation/steps were extremely easy to follow. Worked the first time. And you are correct – CUPS takes a bit of time to load. Thanks.
Hmm, I thought that CUPS and IPP support had been installed in the 2020-02-13 full image. Seemingly not. Anyway, additionally installing cups-ipp-utils, system-config-printer and printer-driver-cups-pdf will not only give you a really nice printer config front-end under the Preferences menu, but also provides a handy Print-to-PDF virtual printer along with IPP support. Messing around with the terrible CUPS web front-end is something I don’t miss.
Best advice on this page.
Thanks a lot!
Thanks from me too.
Great article, well presented and factual.
Really nice guide. How can we add email printing. So we could send email to RPI’s email and print the contents, like most wifi printers do nowadays
Well done – as always. I’d like to make a remark, though. It seems to be quite a challenge to find a guide on printing with CUPS from a Raspberry Pi as a client on the internet. Maybe you would want to look into this as an addition.
can not login as administrator, ??
Read that part again! CUPS won’t allow root logons, too easy to trash the whole system I guess. Log on as a regular user who is in the lpadmin group.
Thank you, this is something I just couldn’t get to work when I tried it in the past.
Thank you for share the info! I’ve tried with my Brother HL-1212 but i couldn’t find my model. My RaspberryPi4 recognize the printer but doesn’t appear the model in the list. What can i do? Thanks!
If you have an Epson printer, and you have problems printing or scanning, try the Epson ESC/P-R driver. Go to Preferences, Add/Remove Software and search for “ESC/P-R”. Check it and hit OK to install. Then, in CUPS, use the ESC/P-R driver.
Neat. I actually did this on my Pi Zero W last year but with tinylinux. very fast to boot which is really ideal for truly wireless setup. sadly I scrapped it halfway due to lack of scanner function. my printer has a scanner that is very useful for the whole home to access it, at least the printing is perfect from Windows to CUPS
there’s another driver that handle scanner but it’s really complex to set up for network use. my target is to be able to print and scan regardless of client OS.
Thanks for this, it got me part of the way, my printer wasn’t on the list of available printers but managed to find some help on the forum to add hp drivers.
Anyway, this is welcome addition on a very difficult topic for a beginner like myself.
Paul, your no alone I have a simple Laserjet P1102 but its been any thing but simple.
This blog is pure gold, I still have a problem, but its a least I’m seeing the printer listed,
Sorry for being rude with my first comment. I could not get trough that step.
Albeit, very happy now at this moment it is working. The Pi with all the advantages is well working and the home office is will be continued in the future. All for as it seems now for about 75% p/w. Even the VPN is perfectly working.
In previous years few manufacturers provided linux drivers for their printers (with HP and Lexmark (formerly IBM) being notable exceptions). Hopefully that has changed, but don’t count on it – especially if wanting to use an old model printer you have lying around at home.
If you already have a printer do try it … but if you’re going out to a buy a printer do your research first starting with the comprehensive database at http://www.openprinting.org/printers
How can we add email printing ?
I have set up printers per your instructions it shows in CUPS it printed but nothing comes out of the printer. It seems like a gate is still closed. I am using a USB connected Brother MFC-7420 and a HP CP1025nw (wireless) and I can’t get either to print even though CUPS shows jobs have gone through as shown below.
ID Name User Size Pages State Control
Hewlett-Packard_HP_LaserJet_CP1025nw-13 Unknown Withheld 1k 1 completed at
Thu May 7 17:12:33 2020
Hewlett-Packard_HP_LaserJet_CP1025nw-15 Unknown Withheld 9k 1 completed at
Thu May 7 17:16:02 2020
I have installed cups and then added my printer. It found it no problem, however the driver doesn’t work properly. It works okay for Black and White, but if you use colour it puts each of the colours on diferent lines. IE black, Cyan, Magenta, yellow. Looks quite funky especially on photos. I tried looking into the driver, but found nobiody else with this issue. I tried from a windows PC printer works fine.
I thought okay lets get a new printer this one is fairly old. So I started looking for new Epson printers however not one of the new printers I found had drivers in cups. So I researched further as to what recommendations there were going back as far as 2016. Two of the suggestions were use Brother or HP as generally you will find drivers. So I started by looking into HP LIP seemed promising so installed HPLIP however found out the latest version available for armhf is 3.18.12. I then went looking for any printers available upto this version. No joy could not find a recent printer available in that list or older one. Looked into later versions of the HPLIP and found a couple of printers that might work, but they were above £300, but with a max budget of £150 or less not much help. I continued looking, but can seem to find no drivers for RPI with latest Raspbian for any current printers.
My conclusion from all this is printing in Linux specifically with RPI and latest RASPBIAN is an absolute mindfield and having spent over a week looking at this trying to find a current ink jet printer, I still have had no luck. I do have another old Epson, but there is no driver for that. While searching I keep finding that current printers are difficult. There appears to be other methods like driverless, but no difinitive guide that is current for current printers. As has been said here already “few manufacturers provided linux drivers” that is even worse for ARMHF. I have not done much with regard scanning, but that appears to be a mindfield at first glance. An RPI in depth article on printing and scanning would be very welcome. Even better would be getting a manufacture to help with this by providing armhf drivers with all new printers. Just looking at the number of pi’s out there that’s a fair amount of sales they would benefit from. Having the latest version of HPLIP working on ARMHF would be another possibility.
As always my views on RPI and all the amazing work you all do is absolutely fantastic.
I forgot to add its a USB printer I have and was also looking for.
I’ve got a £30 Epson XP-225 printer which works perfectly using cups. I installed the cups-ipp-utils, system-config-printer and printer-driver-cups-pdf which gives you a really nice printer config front-end under the Preferences menu. I then installed the ESC/P-R driver from the Add/Remove software and followed that up by adding the printer through the Print Settings app in Preferences – this automatically used the esc/p-r driver and everything works perfectly.
Hope this helps.
For Canon Printers:
Printer Setup On Raspberry Pi
$ sudo apt-get install cups
$ sudo usermod -a -G lpadmin pi
$ sudo apt-get install cups-backend-bjnp
$ sudo service cups restart
browse to https://localhost:631
sign in pi:xxxxx (pi password for the machine)
Click on Discovered Network Printers: Canon_MX860
Model: Canon MX860 series – CUPS+Gutenprint v5.2.11 (en)
Change Default Options: Duplex Print-LongEdge
Click Set Default Options
Click Administration->Set As Server Default
Printers->Maintenance->Print Test Page !!!
Get printer status:
$ lpstat -p -d
pi@Carl:~/Carl/Examples/imu/di_BNO055 $ lpstat -p -d
printer Canon_MX860_series is idle. enabled since Sun 17 May 2020 09:55:22 AM EDT
system default destination: Canon_MX860_series
Print a file:
$ lp resetIMU.py
Very grateful for the main article and for this essential addition re Canon. Thank you.
Thank you. The installation for my HP printer (internet connected) was straightforward and easy :)
All went well up to the stage of browsing in :-This site can’t be reachedlocalhost refused to connect.Try: Checking the connection Checking the proxy and the firewall
Excellent article. I installed on a 8GB Raspberry PI and worked flawlessly. Printed in color with no problems. Thank you for posting it.
I am a newbie with Pi and am trying to add a Brother printer MFC-J475DW. The article was great but I am stuck at adding authourization . I assume user is “pi” but I have no idea what password it is looking for. Any suggestions would be appreciated.
I get it that part of the Raspberry Pi project is to improve computer literacy however with the introduction of the Pi 4 and conversations around the Pi 4 being a desktop replacement can I suggest that a printer plug and play project to support the use of these small low energy, deceptively powerful and useful desktop computers. In office use we just don’t have the time or people to troubleshoot set up issues.
sudo usermod -a -G lpadmin pi
I only get the help for usermod, should I see something else?
Didn’t get very far ! Required to sign in with a username, I have none, I entered pi. And a password, I have none, pressed enter. Then, I get the username and password box again. For the heck of it, I tried pi, lpadmin, password as the password, no joy, of course ! What am I missing ?
Ok just discovered the u/n and p/w, sorry, I didn’t know that. So, looks like I have installed the HP printer, but nothing comes out when I try to print a document. Progress of sorts, not there yet.
Try Administration and then Find New Printer instead of Add Printer… should give you a list of your HP. I did this with my Canon and chose the driverless option then chose the IPP driver option on the Drivers page and this finally got it to work.
This is the closest I have gotten to in resolving setting up the Pi 4 with the HP LaserJet P1102 printer for my grandson. My question has anybody any advise on setting up such a printer, its really a shame to have to battle so much for a general item like a printer.
Just some feed back on my results, Printer nameshows in the libreoffice printer, nothing comes through to the printer, in cups everything looks fine rendering completed, says User withheld? nothing coming through to the printer
I feel like a long lost traveller,
Using HP printer
sudo apt-get install hplip, will load all HP printers, my quest as come to a end, loaded a canon TS5040 in less than 5 mins, my sanity returned to normal
Thank you very much for the simple, clear, and complete information. Not to dis but the Beginners Guide v2, 240 pages does not mention printing once, wow.
Tried to follow this…
$ sudo usermod -a -G lpadmin pi
Error ‘lpadmin’ does not exist.
Fixed it. Required reboot, update, reinstall CUPS.
Hi, I’m trying to get a Samsung ML-2240 working, but keep getting the “filter failed” message and can’t get it to print. Tried the Samsung drivers and the Generic IPP Everywhere, same results each time. The printer status is idle, accepting jobs. Any ideas would be appreciated, thanks in advance!
I forgot to say, I also tried the Splix drivers and got the same problem. Thanks
Thanks For Guiding in Printing HP Printer. I got Solved My Issues of Printing with These Guidance and also from 123.hp.com/setup
I tried at first and couldn’t get it to work. It would recognize my printer but nothing would print. Then I finally went to Administration on CUPS and to Find New Printer instead of Add Printer… from there it found my Canon printer with the driverless option and then when I went to add a driver I just chose IPP (first option) as directed in the article. Worked like a charm! Thanks!
Great step by step article! Thanks. I was trying to follow someone else’s instructions and couldn’t get it the work. They kind of left the part about adding pi the the lpadmin group!!
your instructions don’t seem to work! I am using a RaspberryPi 3 model B. I was able to install CUPS as per but when I tried to give admin rights on CUPS by using the command you suggested “sudo usermod -a -G lpadmin pi”
I got “‘lpadmin’ does not exist”
and when I tried to browse for “http://localhost:631” I got “This site can’t be reached”
so I didn’t get very far using the instruction you provided
Just thought you should know!!
Nice & smooth flow to the page. Worked well
Thank you. I have an Epson WorkForce 4740 connected to our home router and it’s always a pain in the neck. My phone takes one set of drivers, my kids chromebooks take a different set, I thought the pi was gonna be a no-go, but only two attempts later, we’re good. That was almost easy and I haven’t owned a computer in 12 years or more.
I had a problem for printing on Samsung SCX-4300. Do you have additional recommendations for that printer?
Could any one tell me what username and password to use please
The user that you have added in the command to add the user to the lpadmin group, in my case it was the “pi” user with my new/changed password
Thank you very much for your post, I just received my new Pi 4 8Gb a few days ago and I am using it as a Desktop PC, is working fine up to now, but I need to print some documents and with your post I have followed every step and now I am printing all that I need.
Many thanks, worked with a little faffing (probably an idiosyncrasy on my end, the printer did not display any default options to set first run through), but it worked :)
Thanks for this very clear article. I can now print from Libra, the Chromium browser and Leafpad. I would like also to be able to print out Python programs I am working on from IDLE but when I try Print Window and enter OK to the question about Default Printer I get a long error message: ‘Printing command:’lpr /home/pi/progname.py 2>&1’ Printing failed (exit status 0x7f00) /bin/sh l: lpr: not found
What have I missed, or is there another way of printing from IDLE?
Comments are closed