# Temporarily simulate being offline programmatically

Today I am running Mathematica from a computer that is permanently connected to our university network. Because of a number of reasons, I am not allowed to disconnect my computer from our network.

My conflict is that I have some code I wish to test that depends on whether the computer is connected to the Internet or otherwise. How can I pretend my computer is not connected to the Internet for testing?

I know about $NetworkConnected to check if the computer is connected, but temporarily setting it to False with Block does not seem to work. As a simple example of code that needs an Internet connection for testing purposes, you can use CurrencyConvert. ## 2 Answers You can set $AllowInternet to False (or just turn off your WiFi or unplug the cable).

• $AllowInternet looks like it does what I need, but I did not find this in documentation. Sep 5 '19 at 16:29 • @宮元亜衣 You can turn off accessing the internet using the GUI in the preferences. I believe $AllowInternet does exactly the same (and toggling the GUI toggles this variable too). I don't know where it's documented. It's probably undocumented (but widely known). Sep 5 '19 at 16:33
• For limited documentation use Names["*Internet*"] followed by ??\$AllowInternet Sep 5 '19 at 16:52

A general solution for Windows is to run an application (such as Mathematica) inside a Sandboxie sandbox, for which Sandbox Settings > Restrictions > Internet Access has been set to "No program can access the Internet."