0XC0000140

Fix 0XC0000140 STATUS_INVALID_CONNECTION in Windows

Windows apps crash with 0XC0000140 when a program tries to use a broken network connection. Close and reopen the app, then reset the network stack if it keeps happening.

Quick answer for the impatient

Close the crashing app completely, then reopen it. If it crashes again, open Command Prompt as administrator and run netsh winsock reset, restart your PC, and test. That fixes the majority of 0XC0000140 cases.

Why this error happens

This error isn't a hardware failure or a corrupt file. It's a network connection problem under the hood. When a Windows app (a browser, a game, a file-sharing tool, anything that talks to the internet) tries to use a network connection that Windows has already closed or marked as invalid, the system throws 0XC0000140 – STATUS_INVALID_CONNECTION.

Think of it like trying to send a letter using a mailbox that the post office just removed. The app holds a “handle” – a reference number – for the connection. If that handle goes stale (because the network dropped, the Wi‑Fi switched, or the VPN reconnected), the app still tries to use it. Windows says “that connection doesn't exist anymore” and the app crashes.

You'll see this most often with:

  • Apps that stay open for a long time (like a browser with hundreds of tabs)
  • Network shares or mapped drives that disconnect when you resume from sleep
  • VPN clients that switch servers mid-session

Fix steps (try them in order)

Step 1: Close the app and reopen it

Seems obvious, but it works. When the app crashes, its network handles are cleared. Right-click the app icon in the taskbar and choose Close window, or use Ctrl+Shift+Esc to open Task Manager, find the app under Processes, right-click it, and select End task. Then launch the app again.

After reopening, try the action that caused the crash. If it works, you're done. If not, move on.

Step 2: Reset Winsock and the TCP/IP stack

Winsock is the API that Windows apps use to talk over the network. Sometimes it gets corrupted – not permanently, just mucked up. The reset command clears all the junk.

  1. Press Windows key + X and choose Terminal (Admin) or Command Prompt (Admin).
  2. In the black window, type netsh winsock reset and press Enter.
  3. You'll see a message that the reset finished successfully.
  4. Now type netsh int ip reset and press Enter.
  5. After both commands run, close the window and restart your PC.

When Windows restarts, the network stack is fresh. Open the problem app and test. This handles most cases that a simple restart doesn't.

Step 3: Flush DNS cache

A stale DNS entry can point your app to a dead server, and the connection gets dropped mid-handshake. Purging the cache forces a fresh lookup.

  1. Open an administrator Command Prompt again (same as above).
  2. Type ipconfig /flushdns and press Enter.
  3. You should see “Successfully flushed the DNS Resolver Cache.”

No restart needed for this one. Just try the app right after.

Step 4: Check for network adapter power management

Windows often turns off your Wi‑Fi or Ethernet adapter to save power, and when it wakes it up, the connection handle gets scrambled. This is a sneaky cause of 0XC0000140.

  1. Press Windows key + X and select Device Manager.
  2. Expand Network adapters.
  3. Right-click your active adapter (the one with a green icon or the one you're using) and choose Properties.
  4. Go to the Power Management tab.
  5. Uncheck “Allow the computer to turn off this device to save power.”
  6. Click OK.

After doing this, restart the app. If you're on a laptop, you might also want to keep the lid open when you're connected to an external monitor – sleep mode is a common trigger.

Step 5: Reinstall or update the network driver

If the above fail, the problem might be in the driver itself. An outdated or buggy driver can mishandle connection handles.

  1. Go back to Device Manager.
  2. Right-click your network adapter and choose Update driver.
  3. Select Search automatically for drivers. Windows will find and install the latest one.

If Windows says you're already up to date, go to your laptop or motherboard manufacturer's website and download the latest driver manually – don't trust Windows Update for this.

Alternative fixes if the main steps don't work

Run the app in compatibility mode

If the app is older (like a game from 2015), Windows 11 might be handling its network calls differently. Right-click the app's .exe file, pick Properties, go to the Compatibility tab, and check “Run this program in compatibility mode for:” – choose Windows 8 or Windows 7 from the drop-down. Click Apply and test.

Disable IPv6 temporarily

Some apps still choke on IPv6. It's rare, but try it:

  1. Open Control Panel > Network and Sharing Center.
  2. Click your connection type (Ethernet or Wi‑Fi).
  3. Click Properties.
  4. Uncheck “Internet Protocol Version 6 (TCP/IPv6)”.
  5. Click OK and restart the app.

If it solves the crash, you can leave IPv6 off, but you'll lose some modern network features. I'd turn it back on once you stop using that app.

Use the System File Checker

Corrupted system files can cause all sorts of weird errors, including this one. Run:

sfc /scannow

in an administrator Command Prompt. It takes a few minutes – let it finish. If it finds corrupted files, it will repair them, and then you restart.

Prevention tip

The simplest way to avoid 0XC0000140 is to not let your network connections go stale. That means:

  • Close apps that you're not using, especially ones that keep background network connections open (chat apps, sync tools, game launchers).
  • Disable network adapter power management (Step 4) on every adapter you use – it's a one-time change.
  • If you use a VPN, disconnect and reconnect before launching a network-heavy app.

And if you're on Wi‑Fi, keep your laptop plugged in or adjust your power plan to prevent the adapter from sleeping. That alone stops a good chunk of these crashes.

You won't see this error often, but when you do, the steps above handle it. Start with the app restart – it's free and fast. Move to the Winsock reset if you're in a hurry. And if you're comfortable with the command line, you can skip ahead – the reset commands don't hurt anything.

Related Errors in Network & Connectivity
Public Wi-Fi Login Page Not Showing – Simple Fixes 0X000004B5 Fix 0x4B5: Network Profile Won't Open in Windows 10/11 0X80340006 Fix ERROR_NDIS_ADAPTER_NOT_FOUND (0x80340006) network interface not ready 0X0000258B DNS_ERROR_INVALID_ZONE_TYPE (0X0000258B) Fixes

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.