Printers can show unexpected errors at unexpected times such as HP printer offline errors. This error generally arises when the printer is unable to communicate with the system due to improper connection between the devices, slow or disturbed internet, or an internal issue with the printer. Therefore, to resolve this issue and bring your printer back to online mode try-

Checking all the connections between the devices
Remove the printer from the system and add it again
Make sure both the devices (system and the printer) are connected to the same network
Check printer properties, make sure the printer is not set to use in offline mode.