This is usually Windows talking to an old IP address for the printer. Try these in order:
Turn the printer off and on, then restart the PC.
Open Settings > Bluetooth & devices > Printers & scanners, pick the printer and turn off “Use Printer Offline” if it’s on (it’s under Open print queue > Printer menu).
Print a network config page from the printer’s menu and note its IP address.
In Printers & scanners, open Printer properties > Ports and check the port points to that same IP. If it doesn’t, remove the printer and add it again.
In your router settings, give the printer a reserved (fixed) IP so it doesn’t change again.
Step 5 is the real fix: once the address stops changing, the printer stops going offline.