You are currently viewing How to Block a Program from Accessing the Internet in Windows 10

How to Block a Program from Accessing the Internet in Windows 10

When you install a new application, it often phones home for updates, telemetry, or license validation. As a developer or security learner, you may need to prevent a specific program from reaching the internet — to test its offline behavior, stop unwanted data leaks, or isolate a suspicious sample in a lab environment. Windows 10 offers several built-in and third-party methods to achieve this without compromising the rest of your system. Below are three reliable approaches, from the simplest to the most granular.

Why Block a Program’s Internet Access?

Legitimate reasons include:

  • Preventing background telemetry from a development tool you’re profiling.
  • Testing how your own application behaves when the network is unavailable.
  • Stopping a game or media player from fetching ads or updates during a demo.
  • Containing a potentially malicious executable in a sandboxed environment (using a dedicated firewall rule, not just blocking).

Method 1: Windows Defender Firewall with Advanced Security

This is the most precise and permanent method. It creates a custom outbound rule that denies all traffic for a specific executable. No third-party software is needed.

Step-by-Step

  1. Press Win + R, type wf.msc, and press Enter. This opens the Windows Defender Firewall with Advanced Security console.
  2. In the left pane, click Outbound Rules.
  3. In the right pane, click New Rule….
  4. Select Program and click Next.
  5. Browse to the executable you want to block (e.g., C:Program FilesSomeAppapp.exe). You can also use the %ProgramFiles% or %AppData% variables, but the full path is safer.
  6. Choose Block the connection and click Next.
  7. Leave all three profile checkboxes (Domain, Private, Public) selected unless you have a specific reason to limit the rule.
  8. Give the rule a descriptive name (e.g., “Block App Telemetry”) and an optional description. Click Finish.

The rule takes effect immediately. To verify, launch the program and check if it can reach the internet. You can also monitor blocked connections in the Firewall’s monitoring logs (enable logging under Properties → Windows Defender Firewall Properties → Customize for the appropriate profile).

Important Notes

  • This method blocks all outbound traffic for that executable, including DNS queries, HTTP, HTTPS, and any other protocol.
  • If the program spawns child processes (e.g., updater.exe), you may need to block those executables separately.
  • Windows updates and system services are not affected unless you explicitly block them — which is not recommended.

New Outbound Rule Wizard selecting Program

Method 2: The Hosts File (Domain-Level Blocking)

If you only need to block a program from contacting specific domains (e.g., telemetry endpoints or update servers), editing the hosts file is a lightweight alternative. It does not require a firewall rule and works system-wide.

How to Do It

  1. Open Notepad as Administrator (right-click Notepad → Run as administrator).
  2. Go to File → Open and navigate to C:WindowsSystem32driversetchosts. Make sure to select “All Files (*.*)” in the file type dropdown.
  3. Add a line at the bottom of the file for each domain you want to block. Use the format:
127.0.0.1    telemetry.example.com
127.0.0.1    updates.anotherapp.com
  1. Save the file and close Notepad. Flush the DNS cache by opening Command Prompt (as administrator) and running ipconfig /flushdns.

Now any attempt by any program to resolve those domains will point to 127.0.0.1 (your own machine), effectively blocking the connection. This method is ideal for blocking known telemetry URLs, but it won’t stop a program that uses hardcoded IP addresses or connects through a proxy.

Limitations

  • Does not block IP-based connections; only domain names.
  • Some applications may continue to work offline if they fall back gracefully, but others may crash or hang.
  • Editing the hosts file incorrectly can break name resolution for legitimate services — always back up the original file first.

Method 3: Third-Party Firewall with Per-Application Control

For users who want a graphical interface with more flexibility (e.g., temporarily allowing a blocked app, or creating time-based rules), third-party firewalls like TinyWall, GlassWire, or Comodo Firewall offer per-application outbound blocking. These tools sit on top of the Windows Filtering Platform and can be easier to manage than the built-in firewall.

When using a third-party firewall, always download it from the official source to avoid trojanized versions. Configure it to block all outbound traffic by default, then whitelist only the applications you trust. This “default-deny” approach is a core principle of secure system configuration and is especially useful in a lab environment where you test unknown binaries.

Verifying the Block

After applying any of these methods, confirm that the program is indeed cut off from the internet:

  • Open Resource Monitor (resmon.exe) and look at the Network tab. If the blocked program shows zero sent/received bytes while it’s trying to connect, the rule works.
  • Use netstat -an in Command Prompt to check for established connections. A blocked program should not show any remote addresses.
  • For a quick test, run a tool like ping or curl from within the application’s own environment (if possible) to see if it times out.

When to Avoid Blocking

Do not block system-critical processes (e.g., svchost.exe, services.exe, or Windows Update components) unless you fully understand the consequences. Blocking those can break Windows Update, certificate validation, or even your network stack. Similarly, avoid blocking antivirus or security software — they need internet access to update their definitions.

If you are analyzing a suspicious file, block its internet access in a dedicated virtual machine or sandbox, not on your host system. The firewall rule should be one layer of containment, not the only one.

For developers working with C++ or Java applications that rely on external libraries, blocking internet access can help you identify missing dependencies or forced online checks. This is a legitimate debugging technique, not a security bypass.

Final Practical Tip

After creating a firewall rule, test it by launching the program and immediately checking the Firewall’s monitoring log. In wf.msc, right-click the rule you created, select Properties, then go to the Advanced tab and ensure “Edge traversal” is set to “Block” (default). If the program still connects, it may be using a different executable — use Process Explorer (from Sysinternals) to see which child processes it spawns, then block each one individually.