If you suspect the issue may lie with your Wi-Fi network, then another potential workaround is to connect your printer to your Mac using a physical cable. If you have access to an ethernet cable, try wiring your Mac and/or printer directly to your home network to see whether this kickstarts the connection. If you’re still experiencing a weak or intermittent connection, you can often boost a weak signal by swapping wireless for ethernet. You should also try disconnecting your Mac from the network and then reconnecting it. Wherever possible, you should try moving the printer closer to your router to strengthen the connection. If everything seems okay but macOS is still struggling to connect to the printer, then a weak or spotty connection may be to blame. You should also verify that your printer and Mac are connected to the same Wi-Fi network.
If you’re trying to connect over Wi-Fi, then you should check that your network is online and functioning correctly.