Skip to main content

Command Palette

Search for a command to run...

Diagnosing the "Printer Goes Offline After Router Restart" Problem with PowerShell

Updated
3 min read

If you've ever had a network printer that works fine for days and then randomly shows "offline" after a router restart — with no obvious cause — this post covers why that happens and a small PowerShell script I wrote to diagnose it quickly instead of guessing.

The Root Cause

It's almost always a DHCP lease mismatch. Your router assigns IP addresses dynamically. After a restart, the address pool can reassign — and a printer that was previously at 192.168.1.45 might come back at 192.168.1.52. The printer itself is fine and back online. But the printer driver on your machine has the old IP hardcoded into its port configuration, so every print job silently goes nowhere.

This is annoying to diagnose manually because both "sides" report success: the printer's own network status page shows it's connected, and Windows doesn't throw a useful error — it just sits at "offline" or times out.

The Script

I wrote a small PowerShell script that checks all installed printers matching a name pattern, pulls their configured port IP, and pings it to confirm whether the printer is actually reachable at that address:

```powershell

Printer Network Diagnostic Tool

Write-Host "Printer Network Diagnostic" -ForegroundColor Cyan Write-Host "===========================" -ForegroundColor Cyan

\(printers = Get-Printer | Where-Object {\)_.Name -like "Canon"}

if (\(printers.Count -eq 0) { Write-Host "No matching printers found." -ForegroundColor Red } else { foreach (\)printer in \(printers) { Write-Host "`nPrinter: \)(\(printer.Name)" -ForegroundColor Green Write-Host "Status: \)($printer.PrinterStatus)"

    \(port = Get-PrinterPort -Name \)printer.PortName -ErrorAction SilentlyContinue
    if ($port.PrinterHostAddress) {
        Write-Host "Configured Port IP: \((\)port.PrinterHostAddress)"
        \(ping = Test-Connection -ComputerName \)port.PrinterHostAddress -Count 1 -Quiet
        Write-Host "Reachable at this IP: $ping"
        
        if (-not $ping) {
            Write-Host "MISMATCH DETECTED - driver port IP is likely stale" -ForegroundColor Yellow
        }
    }
}

} ```

If Reachable comes back False, you've confirmed the mismatch — the printer driver is pointing at an address that no longer responds.

I've put this script along with a companion batch file (for clearing a stuck print spooler — the other common cause of "offline" errors) in a small repo: canon-printer-setup-tools, MIT licensed.

Why DHCP Reservation Is the Real Fix

The script above is diagnostic — it tells you what's wrong, not a permanent fix. The actual fix is binding the printer's MAC address to a fixed IP in your router's DHCP settings (usually under "DHCP Reservation" or "Address Reservation"). Once that's done, the printer always gets the same address, the driver port never goes stale, and this entire class of problem disappears.

For anyone wanting a more complete walkthrough of the full setup process — including router-specific DHCP reservation steps — PrinterSolved — Canon Printer Setup covers it for Windows and Mac.

This is a small thing, but it's saved me from the "is it the printer or the network?" guessing game more times than I'd like to admit.