$linuxjunkies
>

Turn a Raspberry Pi into a Network Print Server

Turn any USB printer into an AirPrint-capable network printer using a Raspberry Pi, CUPS, and Avahi — with SD card-friendly tuning included.

BeginnerUbuntuDebianFedoraArch8 min readUpdated June 7, 2026

Before you start

  • Raspberry Pi (any model with USB) running a 64-bit OS and connected to your LAN
  • A USB printer physically connected to the Pi
  • SSH access or a keyboard/monitor attached to the Pi
  • sudo privileges on the Pi user account

A USB printer gathering dust can become a network resource any device on your LAN can reach — including iPhones and Macs via AirPrint — with nothing more than a Raspberry Pi, CUPS, and Avahi. This guide walks through installation, a few Pi-specific tweaks to protect your SD card, and broadcasting the printer so clients discover it automatically with zero driver installation.

Install CUPS and Avahi

Debian/Ubuntu (Raspberry Pi OS, Ubuntu Server for Pi)

sudo apt update && sudo apt install -y cups avahi-daemon

Fedora / RHEL family (if you're running Fedora IoT or Rocky on a Pi)

sudo dnf install -y cups avahi

Arch (Arch Linux ARM)

sudo pacman -Sy cups avahi

Enable and start both services immediately and on every boot:

sudo systemctl enable --now cups avahi-daemon

Allow Your User to Manage Printers

CUPS restricts printer administration to members of the lpadmin group. Add your user (replace pi with your actual username):

sudo usermod -aG lpadmin pi

Log out and back in, or run newgrp lpadmin in your current shell so the group membership takes effect without a full re-login.

Open the CUPS Web Interface to the Network

By default CUPS only listens on localhost. Edit /etc/cups/cupsd.conf to let machines on your LAN reach the admin panel. The relevant blocks look like this after editing:

sudo nano /etc/cups/cupsd.conf

Find and change the Listen line, then broaden the access directives:

# Change:
#   Listen localhost:631
# To:
Port 631

# Under , add:
Allow @LOCAL

# Under  and , add:
Allow @LOCAL

The finished <Location /> block should look like:

<Location />
  Order allow,deny
  Allow @LOCAL
</Location>

Save the file, then restart CUPS:

sudo systemctl restart cups

You can now browse to http://<pi-ip>:631 from any machine on your LAN.

Pi-Specific Tuning: Protect the SD Card

CUPS writes job logs and spool data constantly. On a Pi running from a microSD card this accelerates wear. Apply two changes to reduce unnecessary writes.

Reduce log verbosity

In /etc/cups/cupsd.conf, set log level to warnings only:

LogLevel warn
MaxLogSize 1m

Move the spool directory to RAM (tmpfs)

Add this line to /etc/fstab — it mounts a 64 MB tmpfs over the CUPS spool directory at boot. Jobs in progress will be lost on power loss, which is acceptable for a home/small-office print server:

echo 'tmpfs /var/spool/cups tmpfs defaults,noatime,size=64m 0 0' | sudo tee -a /etc/fstab
sudo mount -a

Restart CUPS one more time to confirm it is happy with the new spool location:

sudo systemctl restart cups

Add the Printer via the CUPS Web UI

  1. Connect the USB printer to the Pi and open http://<pi-ip>:631 in a browser.
  2. Go to Administration → Add Printer. Authenticate with your Pi user credentials.
  3. Select the printer from the Local Printers list. CUPS auto-detects most USB printers.
  4. Give it a short, memorable name with no spaces (e.g. HP_LaserJet). Check Share This Printer.
  5. Choose the correct PPD/driver from the list, or select a close model if an exact match isn't present. For many modern laser printers, Generic PostScript Printer works reliably.
  6. Click Add Printer, then set default options (paper size, duplex) and click Set Default Options.

Alternative: Add from the command line with lpadmin

If you prefer the terminal, first find the device URI:

lpinfo -v

Output will vary; look for a line like direct usb://HP/LaserJet%20.... Then add it:

sudo lpadmin -p HP_LaserJet \
  -E \
  -v usb://HP/LaserJet%201020 \
  -m drv:///sample.drv/generpcl.ppd \
  -o printer-is-shared=true

Apple AirPrint uses DNS-SD (Bonjour) to discover printers. Avahi provides that on Linux. CUPS 2.x and later can generate the service record automatically — just confirm the Avahi socket is available to CUPS:

sudo systemctl is-active avahi-daemon

If it prints active, CUPS will announce shared printers automatically when a printer is shared. No extra configuration is required on Raspberry Pi OS Bookworm / Ubuntu 22.04+ with CUPS 2.4+.

On older CUPS (check with cups-config --version), you may need to create a manual Avahi service file. Replace the values to match your printer name and URI:

sudo nano /etc/avahi/services/airprint-HP_LaserJet.service
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name>HP LaserJet (Pi)</name>
  <service>
    <type>_ipp._tcp</type>
    <subtype>_universal._sub._ipp._tcp</subtype>
    <port>631</port>
    <txt-record>txtvers=1</txt-record>
    <txt-record>qtotal=1</txt-record>
    <txt-record>rp=printers/HP_LaserJet</txt-record>
    <txt-record>ty=HP LaserJet</txt-record>
    <txt-record>adminurl=http://raspberrypi.local:631/printers/HP_LaserJet</txt-record>
    <txt-record>pdl=application/octet-stream,application/pdf,image/jpeg,image/pwg-raster</txt-record>
    <txt-record>Color=F</txt-record>
    <txt-record>Duplex=F</txt-record>
    <txt-record>usb_MFG=HP</txt-record>
    <txt-record>usb_MDL=LaserJet</txt-record>
    <txt-record>air=none</txt-record>
  </service>
</service-group>
sudo systemctl restart avahi-daemon

Verify Everything Works

Check service status

systemctl status cups avahi-daemon

Send a test page

echo 'Test page from Pi' | lp -d HP_LaserJet

Confirm AirPrint visibility from an Apple device

On an iPhone or Mac, open any app with a Print option (Safari, Files, etc.) and tap/click Print. The Pi printer should appear in the printer list within a few seconds if your phone and Pi are on the same subnet.

Check Avahi is broadcasting

avahi-browse -at | grep -i ipp

You should see your printer's service record listed.

Troubleshooting

  • Printer not detected by CUPS: Run lsusb to confirm the Pi sees the printer at all. Some HP printers need the hplip package (sudo apt install hplip). Unplug and replug the USB cable after installing.
  • Web UI returns 403 Forbidden: The Allow @LOCAL directives are missing or the user isn't in the lpadmin group. Re-check both and restart CUPS.
  • AirPrint printer not visible on iPhone: Confirm both devices are on the same VLAN/subnet — multicast DNS does not cross router boundaries by default. Disable any AP isolation setting on your router.
  • Jobs stuck in queue: Check the CUPS error log with sudo journalctl -u cups -n 50. A missing PPD or wrong device URI is the most common cause; remove the printer and re-add it with the correct settings.
  • SD card wearing out faster than expected: Verify the tmpfs mount is active with mount | grep spool. If it isn't mounted, check /etc/fstab for typos.
tested on:Debian 12 (Bookworm) / Raspberry Pi OS BookwormUbuntu 24.04 LTS (Ubuntu Server for Raspberry Pi)Arch Arch Linux ARM (rolling, 2024)

Frequently asked questions

Does this work with any USB printer?
Most USB printers work out of the box. Older HP printers often need the hplip package for full feature support. Very old GDI/host-based printers that rely entirely on Windows drivers are generally not compatible with CUPS.
Can Windows PCs also print to the CUPS server?
Yes. Windows 10 and 11 support IPP printing natively. Point a new printer at http://<pi-ip>:631/printers/<printer-name> using the Internet Printing Protocol, and Windows will pull a generic driver automatically.
Is it safe to expose the CUPS web UI on my local network?
It's acceptable for a trusted home or small-office LAN. Do not forward port 631 through your router to the internet. For an untrusted or segmented network, restrict the Allow directive to a specific subnet like 192.168.1.0/24 instead of @LOCAL.
Why use tmpfs for the spool directory — won't I lose print jobs on reboot?
Yes, any job queued but not yet printed will be lost on an unexpected power cut. For a home print server this is a reasonable trade-off. If reliability matters more than SD card life, skip the tmpfs mount and consider running the Pi from a USB SSD instead.
AirPrint doesn't show the printer on my iPhone even though CUPS is running. What's wrong?
The most common cause is AP (access point) isolation on your Wi-Fi router, which blocks multicast DNS between wireless clients and wired devices. Disable client/AP isolation in your router's wireless settings. Also confirm the Pi and iPhone are on the same subnet.

Related guides