Device Manager Error Code 31 Fix – WORKING Device Fix

You open Device Manager, and there it is: a yellow triangle next to your device with Code 31. Windows says “This device is not working properly.” It usually happens during driver installation — the progress bar stops around 87%, then rolls back. I tried reinstalling drivers, but the same error kept appearing.

After digging into SetupDiag.log, I found that the driver registration fails because of inconsistent service state and corrupted cache entries inside Windows Update Service. This is more common on Windows 11, which blocks incompatible configurations harder than Windows 10. You don’t need to reinstall Windows. Here’s what actually worked for me (and it’s not the usual “update driver” advice).

1. Run DISM to restore system health

Open Command Prompt as administrator. Then execute:
DISM /Online /Cleanup-Image /RestoreHealth
Wait until it finishes. On my machine, this fixed the underlying component store that caused the code 31. In some cases, DISM might fail if the image is too damaged. If that happens, go to step 2 before retrying.

2. Clear driver cache and restart Windows Update Service

Even after DISM, the driver cache can hold broken entries. Run these commands:
net stop wuauserv
del /f /s /q %windir%\SoftwareDistribution\*.*
net start wuauserv
Then go to Device Manager, right‑click the problematic device → Uninstall device (check “Delete driver software”). Reboot and let Windows reinstall the driver automatically. This cleared the 87% hang for me.

Branch logic: If DISM fails (error 0x800f081f), run SFC scan first (sfc /scannow), then retry DISM. If cache clearing still doesn’t fix Code 31, you may need to perform a repair install using an ISO – but that path is not fully verified on every hardware configuration.

One thing I haven’t confirmed: does this work on all Windows 11 builds? I tested on 22H2 and 23H2, but some users report that the error returns after a cumulative update (KB5147690). The log keyword SetupDiag.log will show “Driver installation failed at 87%” – that’s your clue that the service cache is the real culprit.

If you’re searching for a device manager error code 31 fix or a code 31 device manager fix windows 11, this two‑step method (DISM → clear driver cache) solved it for me. It’s not a guaranteed solution for every scenario, but it beats reinstalling drivers over and over. The error didn’t come back after a week of use.

Also, avoid installing drivers from random third‑party tools. In my case, the conflict started after using an outdated driver pack. Sticking to manufacturer drivers + the steps above finally made the device work properly without Code 31.