Setting up CUPS and installing local printer in Ubuntu Server

in cups, printer, setup, ubuntu server

After my first Ubunutu Server install (Hardy Heron LTS 8.04), I couldn’t get the local printer setup. Here’s how I fixed it.

I’m a linux newbie and was feeling a bit lost without GUI. Several articles I read said gnome on a server was an unnecessary security risk, so I installed Webmin. But I couldn’t add the printer via Webmin Hardware -> Printers Administration. I kept getting the following error:

Failed to save printer: lpadmin failed :
lpadmin: No such file or directory

I have a brother MFC printer, so I first made sure the printer drivers where installed. I found info on the Ubuntu Brother MFC drivers and installed the package via Webmin System -> Software Packages. But trying to add the printer via Webmin still gave the same error.

I decided to try to install the printer another way, and found out that CUPS was likely the way to do it. I checked the package manager to make sure CUPS was installed. It was.

I then tried the CUPS web interface to see if I could install from there. But I couldn’t get to it. I found some CUPS documentation and realized that by default the CUPS server only listens to requests from localhost. So, I edited the etc/cups/cupsd.conf file:

  • comment out:
    #Listen localhost:631
  • add : (my server host name is “alexander”)
    Listen alexander:631
  • turn on browsing:
    Browsing On

I restarted the CUPS server

sudo /etc/init.d/cupsys restart

and and tried to connect to https://alexander.mydomain.com:631/, but I got a 403 Forbidden error.

After some searching, I discovered that I had change the blocks to add access from the local network. I add “Allow @LOCAL” lines to etc/cups/cupsd.conf file. Changed parts of the file noh now looked like this:

# Only listen for connections from the local machine.
# Listen localhost:631
Listen alexander:631  #added by Carl (alexander is the server's host name)
Listen /var/run/cups/cups.sock

# Show shared printers on the local network.
Browsing On  #turned on by Carl
BrowseOrder allow,deny
BrowseAllow all
BrowseAddress @LOCAL

# Default authentication type, when authentication is required...
DefaultAuthType Basic

# Restrict access to the server...
<Location />
 Order allow,deny
 Allow localhost  #added by Carl
 Allow @LOCAL     #added by Carl
</Location>

# Restrict access to the admin pages...
<Location /admin>
 Order allow,deny
 Allow localhost  #added by Carl
 Allow @LOCAL     #added by Carl
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
 AuthType Default
 Require user @SYSTEM
 Order allow,deny
 Allow @LOCAL   #added by Carl
</Location>

Another CUPS server restart and… I was in! What a beautiful sight: the CUPS GUI.

Now life was good. I clicked “Add Printer,” walked through the GUI steps, and in about 60 seconds the printer was installed.

cha-ching!

Update for Ubuntu 10.04:

  • needed to add to cupsd.conf file:  ServerAlias *
  • For my Brother MFC 7420, I had to install: sudo apt-get install brother-cups-wrapper-laser

Update for Canon Printers (thanks Jay!)
Per Jay’s comment below, if you have a Canon printer, don’t use the default cups drivers. Download them from Cannon instead and you should be all set.

fabio September 28, 2008 at 3:23 pm

Thank a lot for this article.
I’ve got this kind of problem on Ubuntu server with webmin + cups.
Now it’s ok. It works.

kronk021 October 7, 2008 at 4:08 pm

Thank you SOO much!!!

Anonymous January 18, 2009 at 11:08 am

Thanks for the article. I was having the exact same problem with webmin and this worked beautifully!

microgluf May 28, 2009 at 12:07 pm

A simpler way to connect to the CUPS interface is to use SSH redirection.
Make sure SSH is installed (it should be !)
then simply ssh to your server as follows:

ssh -L8000:localhost:631 username@ip_address

In other words, port 8000 (can be anything unused on your local machine) points to the localhost:631 of your remote server.

Open a browser and connect to http://localhost:8000

Simon Ives June 27, 2009 at 4:26 am

Thank you very much. This saved me the trouble of going through the CUPS manual and having to figure this out while in a hurry.

Much appreciated.

pankipan4e December 30, 2009 at 4:50 am

The same scenario on my server, and I was pretty pissed. Googled to here and followed the steps and solved the problem. Thanks , your lifesaver :)

David May 10, 2010 at 8:50 pm

Hi,
Thanks for this. I now have the CUPS GUI working. I am using a Canon LBP3100 local printer. I can add it but it won’t print. Have tried switching off and on, disconnecting the USB cable and restarting.
I also print to a network printer and that works fine.
Any ideas?

anonimous June 11, 2010 at 3:28 am

Thanks!

Michael June 30, 2010 at 9:37 am

Thanks for the info. I did exactly as you specified and was able to get into the web interface.

CapnKernel May 5, 2011 at 9:02 am

Carl! Thanks, your article really helped me! I worked out that CUPS was rejecting advances from other machines on my network, but didn’t know what to put in cupsd.conf. Your article set me (and my computer) straight!

Rangler July 3, 2011 at 10:11 pm

Big help, big help. And spureltaive news of course.

Tom July 20, 2011 at 6:24 pm

Nice job, if you’re still following this post, it was still valid on version 11.04 of ubuntu server. NICE, wasn’t really expecting it to work. Thanks for the post!

sp November 5, 2011 at 12:30 pm

I have a Printer connected directly to network. What will be the Port number for the printer? I simply connected the printer to the network and the network page doesnot have the port information that i need to put in the webmin add printer page

Editor November 6, 2011 at 11:05 am

Sanjit, sorry to hear you are having trouble. Please provide some specs for you system and hopefully we can help.

Jay D Whitfield November 14, 2011 at 7:18 pm

Great note. Worked for me excepted I had to add a user ‘cupsys’ to gain access. Also if anyone has a canon, do not attempt to use the default drivers in the cups interface. The drivers from canon worked for me. I hope this save someone a few hours.

Editor November 19, 2011 at 3:28 pm

Thanks Jay! I updated the post with your info.

Thomas January 6, 2012 at 4:28 pm

Thanks for the article. Had all this set up before my old server died. Couldn’t remember how it was done, but got it up now.

trentj February 4, 2012 at 11:20 pm

This worked beautifully. Thanks!

Ragger June 14, 2012 at 10:39 am

Thanks for this…..got in a minute….just forgot howto

Comments on this entry are closed.

Next post: