Setup a Print Server using Raspberry Pi & CUPS: Part 2

Anirudh Gupta
6 min readJun 22, 2019

This is the continuation of the Part 1 of the article, where we covered the initial setup of our Raspberry Pi. If you have not setup your Pi, I recommend you to follow Part 1.

In this part, we will setup our printer server software CUPS on the Pi. A computer (Raspberry Pi) running CUPS is able to accept jobs from client devices, process them and pass it on to the appropriate printer to print.

Setup Print Server Software CUPS

Open a new terminal window (or ssh) on your Pi and follow.

1. Update Pi

We need to be sure that our Pi runs the latest software.

sudo apt-get update
sudo apt-get upgrade

With this done, reboot the Pi.

sudo reboot

2. Use Static IP

We need to make a few system tweaks so that we can use the Pi as a “server” on the network. We need to set the DHCP client to use a static IP address; by default, the DHCP client might pick any available network address, which would make it tricky to know how to connect to the Raspberry Pi over the network.

We start by editing the DHCP config file

sudo nano /etc/dhcpcd.conf

Scroll to the bottom of the file and add one, or both of the following snippets, depending on whether you want to set a static IP address for a wired connection (eth0) or a wireless connection (wlan0).

interface eth0

static ip_address=
static routers=
static domain_name_servers=

interface wlan0

static ip_address=
static routers=
static domain_name_servers=
  1. interface: Network interface you are setting the configuration for.
  2. static ip_address: This is the IP address that you want to set your device to. (Make sure you leave the /24 at the end)
  3. static routers: This is the IP address of your gateway (probably the IP address or your router)
  4. static domain_name_servers: This is the IP address of your DNS (probably the IP address of your router). You can add multiple IP addresses here separated with a single space.

Save the file using Ctrl + X then press Y followed by Enter.

Finally, reboot your Pi.

Note: You may have a different network configuration where address class and IP address may differ. Perform this step carefully, else the Pi can suffer connectivity issues. To get an idea of what ip address you must use, run and observe inet and netmask values:

ifconfig -a

3. Install CUPS

Next, we need to install CUPS. This will take some time but will install CUPS and other dependencies like samba, perl and several other software or libraries.

sudo apt-get install cups

4. Configure CUPS

We need to make some changes to the configuration file of CUPs. The config file can be edited using:

sudo nano /etc/cups/cupsd.conf

Change/add the following lines to the configuration file. These changes will allow us to interact with CUPS panels.

# listen on all interfaces
#Listen localhost:631
# Restrict access to the server...
<Location />
Order allow,deny
Allow @Local


# Restrict access to the admin pages...
<Location /admin>
Order allow,deny
Allow @Local


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


If you want to change the port (CUPS operate on port 631 by default), find this line and change it.

Port 631

Further, if you want to access CUPS Web Interface from a domain, you need to allow requests from those domains. Add the following lines before <location> tags.

# You can allow all domains to access the interface
ServerAlias *
# or provide a specific name.
# ServerAlias

Save the file using Ctrl + X then press Y followed by Enter.

5. User & Network Access Settings

Next we add the Pi user to the lpadmin group. This gives the Raspberry Pi the ability to perform administrative functions of CUPS without necessarily being a super user.

sudo usermod -a -G lpadmin pi

We need to ensure that CUPS is accessible across entire network.

sudo cupsctl --remote-any

Finally, restart CUPS to effect changes

sudo /etc/init.d/cups restart

6. Setup Samba

Samba is the standard Windows interoperability suite of programs for Linux and Unix. It will allow Windows system to communicate with our CUPS server running on the Pi, and will allow us to send print commands from Windows.

sudo apt-get install samba

We need to edit its configuration:

sudo nano /etc/samba/smb.conf

Scroll to print section, change guest ok = no to guest ok = yes

guest ok = yes

Scroll to printer driver section, change read only = yes to read only = no

read only = no

Save the file using Ctrl + X then press Y followed by Enter.

Finally, restart samba to effect the changes:

sudo /etc/init.d/smbd restart

7. Printer Setup

7.1 Installing Printer Drivers

You may need to install drivers for your printers. You can trying skipping this step (7.1) and proceed to next step. If next step fails, then you need to figure out “How to install drivers for <insert printer model> on Debian Raspberry Pi OS”. You can google it.

I know the process for HP printers, run:

sudo apt-get install hplip

Optionally, also install GUI:

sudo apt-get install hplip-gui

Then run (select USB if printer is USB based, and select Download plug-in from HP when prompted):

hp-setup -i

7.2 Adding Printer to CUPS

This is the last and most easiest step to do. From your PC, connect to the same network as your Pi. Open a web browser and go to the CUPS homepage by entering your Pi’s IP address followed by “:631” which is port address on which CUPS is communicating. It may be different in case you changed the port. The browser may show a warning “Connection not secure”, click “Proceed Anyway”.

To know your Pi’s IP address, you can run the command hostname -I from your Pi. In my case, the web address is:

Go to Administration page and click Add Printer. Make sure that your printer is switch on and connected to your Pi via USB. Follow the prompts and setup the printer. Before the final step, ensure that you check the “share this printer” checkbox. Finally, you can print a test page on Printers page to verify if everything works.

Note: Your printer may not be listed in “Local Printers” on the Add Printer page. If that is the case, you need to install the required printer drivers on your Pi. Search the Internet for a way to install your printer drivers on Linux. In my case (HP Printers), I had to install hplip from here or from above step. The latest version didn’t compile on my Pi (It didn’t support latest Raspbi OS at that time). I had to use version 3.18.6 with custom setup and uncheck Qt4 & Qt5 interfaces.

This completes our CUPS setup. The final task is to send print commands using the connected devices. After this, you will be able to print using Linux, Windows, Mac, Android and iOS wirelessly. We need not install any printer drivers for that. Continue to the last part, where we finally print wirelessly.

PS: After adding a printer, there was a problem occurred. For some reason, the printer would only print first few X jobs, and ignore the remaining jobs. To continue printing, I had to either restart my Pi, or restart my printer. The following command fixed my problem:

# Replace PRINTERNAME with the name used in step 7. Eg: m1136
lpadmin -p PRINTERNAME -o usb-no-reattach-default=true
# Restart your Pi
sudo reboot