How to Automatically Clear the Windows 11 DNS Cache on Boot Using Task Scheduler

The Domain Name System (DNS) cache stores the IP addresses of websites you have recently visited, helping web pages load faster by bypassing the DNS lookup process. However, if a website changes its server infrastructure, a stale DNS cache can cause connection errors or route you to an outdated page. While you can flush the cache manually using the Command Prompt, automating the process via the Windows Task Scheduler ensures your computer starts every session with a completely clean slate.

Creating the Flush DNS Task

Windows 11 includes a built-in Task Scheduler that allows you to execute commands and scripts based on system events, such as starting the computer or logging in.

  1. Click the Start button, type Task Scheduler, and press Enter.
  2. In the right-hand “Actions” pane, click on Create Task… (do not select Basic Task).
  3. In the General tab, enter a descriptive name, such as Flush DNS on Boot.
  4. Check the box labelled Run with highest privileges. The ipconfig command requires administrator rights to manipulate network caches successfully.
  5. Select the radio button for Run whether user is logged on or not to ensure it runs silently in the background.

Setting the Boot Trigger

Next, you must define exactly when the task should execute.

  1. Switch to the Triggers tab and click New.
  2. In the “Begin the task” dropdown menu, select At startup.
  3. (Optional) If you have a slow-booting PC and want to ensure network services are fully initialized before flushing, check the Delay task for box and select 30 seconds.
  4. Ensure the Enabled box at the bottom is checked and click OK.

Configuring the Command Action

Finally, you need to define the exact command line instruction the task will run.

  1. Switch to the Actions tab and click New.
  2. Ensure the “Action” dropdown is set to Start a program.
  3. In the Program/script box, type exactly:
    ipconfig
  4. In the Add arguments (optional) box, type exactly:
    /flushdns
  5. Click OK to save the action.

Finalizing the Task

Review the Conditions tab to ensure the task isn’t unnecessarily restricted. By default, Windows tasks won’t run if a laptop is on battery power. If you want this to run regardless of power state, uncheck Start the task only if the computer is on AC power.

Click OK at the bottom of the main Create Task window. Windows will prompt you to enter your administrator password to authorize the creation of this highly privileged task.

Once saved, you can close the Task Scheduler. From now on, Windows 11 will automatically execute the ipconfig /flushdns command transparently in the background every time you turn on your PC, ensuring your network connections are always freshly resolved.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.