Developing SharePoint hosted app, if somehow you are not able to connect with your tenant site and provide to work in offline mode and your project go to offline mode in Visual Studio. Now to come back online to deploy your app:
Open SharePoint project
Select solution
Click F4
You will see: Server Connection
Select : Online
Cheerssssssssss :)