The printer becoming offline and unavailable for printing is a commonly occurring issue in most printers, especially those that are connected to a network. It can occur quite unexpectedly and prevent you from taking printouts. This issue can still occur even if you have kept the printer on and ready to print. The device will go offline, which prevents communication between your printer and computer. Several trivial issues such as loose cables or a paper jam can also cause your printer to go offline.
https://www.customersupportcare.com/hp-printer-support.html