I’m assuming this is for wifi and you have already entered the password into the printer.
I didn’t find the instructions for your model, but I have an HP that goes offline all the time (so frustrating) and what used to work was running to trouble shooter. On my laptop I would go into settings then printers then pick the printer then manage then run the troubleshooter and it would fix it. That stopped working recently.
Then I would turn the printer off and on and it would work. Then that stopped working.
Then, recently I needed to scan something, and at first it was offline as I expected it would be, but hope springs eternal, I eventually I got it working again, and I cannot remember what I did. I got some pop up and clicked something and it worked. Now, I have been able to print again since fixing the link when I needed to scan. I hope one of those things I mentioned was helpful.