Note: For non-Linux systems, values greater than or equal to 600 seconds (10 minutes) will be ignored by mongod and mongos . For Linux, values greater than 300 seconds (5 minutes) will be overridden on the mongod and mongos sockets with a maximum of 300 seconds. 

## On Linux systems : 

• To view the keep alive setting, you can use one of the following commands: 

sysctl net.ipv4.tcp_keepalive_time 

Or: 

cat /proc/sys/net/ipv4/tcp_keepalive_time 

The value is measured in seconds. 

• To change the tcp_keepalive_time value, you can use one of the following command: 

sudo sysctl -w net.ipv4.tcp_keepalive_time=<value> 

Or: 

echo <value> | sudo tee /proc/sys/net/ipv4/tcp_keepalive_time 

These operations do not persist across system reboots. To persist the setting, add the following line to /etc/sysctl.conf : 

net.ipv4.tcp_keepalive_time = <value> 

On Linux, mongod and mongos processes limit the keepalive to a maximum of 300 seconds (5 minutes) on their own sockets by overriding keepalive values greater than 5 minutes. 

## For OS X systems : 

• To view the keep alive setting, issue the following command: 

sysctl net.inet.tcp.keepinit 

• To change the net.inet.tcp.keepinit value, you can use the following command: 

sysctl -w net.inet.tcp.keepinit=<value> 

The above method for setting the TCP keepalive is not persistent; you will need to reset the value each time you reboot or restart a system. See your operating system’s documentation for instructions on setting the TCP keepalive value persistently. 

## For Windows systems : 

• To view the keep alive setting, issue the following command: 

reg query HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v KeepAliveTime 

The registry value is not present by default. The system default, used if the value is absent, is 7200000 millisec- onds or 0x6ddd00 in hexadecimal. 

• To change the KeepAliveTime value, use the following command in an Administrator Command Prompt , where <value> is expressed in hexadecimal (e.g. 0x0124c0 is 120000): 

reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ /v KeepAliveTime /d <value> 

Windows users should consider the Windows Server Technet Article on KeepAliveTime 30 for more information on setting keep alive for MongoDB deployments on Windows systems. 

