Also, check the IP address in the app on your tablet—it will change after switching modes. Use that new IP to connect.
I had the same issue with my Lenovo Tab P11 Pro Gen 2, and I solved it by going into USB Preferences and switching from ‘File Transfer’ mode to ‘USB Tethering’ mode. This fixed the connection issue for me.