Windows Internet Disconnecting When Computer Idle


On Windows 11 it appears that the internet disconnects automatically when the computer is idle. This is a problem when trying to publish large files in the background. I am using curl from the MBS plugins to publish to FTP.

I have found some instructions for Windows 10 to turn this setting off using the Power Management settings but these settings don’t exist on Windows 11.

Is there anyway to maintain an internet connection while a Windows computer is idle or turn off this setting on Windows 11?

I am testing on Parallels but this also happens on other Windows computers.


i think your device use hibernation
my device runs in german but you should find it here with similar names.
windows settings / system / power & accu / monitor and energysavings

Thanks for the response Markus.

My Windows computer is set to never go to sleep/hibernate and to never turn off the screen.

I looked Settings-> System->Power & Battery and Settings->Network & Internet and I cannot find anything related to maintaining the internet connection when computer is idle.

I also find it strange that there is no way to maintain a connection on an app specific basis if you wanted to leave something to publish in the background.

This link might steer you toward a solution:

Thank you Bob! That link was very helpful!

These instructions not only seems overly complicated, but my version of Windows 11 doesn’t have the “Networking Connectivity in Standby” option as shown in one of the steps there.

I will look into the other methods but this doesn’t seem to be a good long term solution to suggest to potential users. I am surprised this can’t easily be adjusted. I leave my Mac to upload large files all the time.

I think previously while a socket was running you could use a timer to call socket.Poll on the Mac, but this doesn’t seem necessary anymore.

In any case, thank you for the potential solution and I will continue, and hope, there is a more user friendly solution here.

1 Like

NP and I hope it leads to a good solution. My paying work is done on Windows Server and I don’t administer that, and I don’t run Windows on my own machines at present, so I have no actual experience to draw on. Please do share your ultimate findings here though. It’s going to come in handy for a lot of people, including quite probably me at some point. I have an interest in large file transfer management.

Just an update here. Thanks to Norman Palardy for a fix. We can disable app nap on Windows and it seems to work ok now. The internet connection is not disconnected while using it.

You can prevent and allow the app from “sleeping” while doing something.

In a module add this private property;

Private Property m_previous_state As Uint32

Then create these two methods;

Protected Sub AllowMachineSleep()
  #If TargetWindows
    // we dont keep a stack of previous states so if the state is 0 then we've already set the state back
    If m_previous_state = 0 Then
    End If
    Soft Declare Function SetThreadExecutionState Lib "Kernel32.dll" ( new_state As UInt32 ) As UInt32
    m_previous_state = SetThreadExecutionState( m_previous_state )
    m_previous_state = 0
End Sub
Protected Sub DisallowMachineSleep()
  #If TargetWindows
    // Value    Meaning
    // 0x00000040
    // Enables away mode. This value must be specified With ES_CONTINUOUS.
    // Away mode should be used only by media-recording And media-distribution applications that must perform critical background processing on desktop computers While the computer appears To be sleeping. See Remarks.
    // 0x80000000
    // Informs the System that the state being set should remain In effect Until the Next Call that uses ES_CONTINUOUS And one Of the other state flags Is cleared.
    // 0x00000002
    // Forces the display To be on by resetting the display idle timer.
    // 0x00000001
    // Forces the System To be In the working state by resetting the System idle timer.
    // 0x00000004
    // This value is not supported. If ES_USER_PRESENT is combined with other esFlags values, the call will fail and none of the specified states will be set.
    // according to
    // EXECUTION_STATE    UInt32    name As UInt32
    // EXECUTION_STATE SetThreadExecutionState([in] EXECUTION_STATE esFlags);
    // If the Function succeeds, the Return value Is the previous thread execution state.
    // If the Function fails, the Return value Is NULL.
    // we dont keep a stack of previous states so if the state is NOT 0 then we've already been called
    If m_previous_state <> 0 Then
    End If
    Const ES_AWAYMODE_REQUIRED = &h00000040
    Const ES_CONTINUOUS = &h80000000
    Const ES_DISPLAY_REQUIRED = &h00000002
    Const ES_SYSTEM_REQUIRED = &h00000001
    Const ES_USER_PRESENT = &h00000004
    Soft Declare Function SetThreadExecutionState Lib "Kernel32.dll" ( new_state As UInt32 ) As UInt32
    m_previous_state = SetThreadExecutionState( ES_CONTINUOUS + ES_SYSTEM_REQUIRED + ES_AWAYMODE_REQUIRED )
End Sub



when you don’t want the connection to be able to disconnect while idle.

When you are done with the task, you can call;

Call the module.AllowMachineSleep()

Has been working well so far and also makes sure the allow method is not called more than once if it is already enabled.