I have a network problem on my MacOS that i need to troubleshoot. I know that TCP socket has internal timeout that will close connection if remote party is not responding (but no graceful disconnect either). Is it any command/tool i can use to check exact value of this timeout(s)?

5 Answers 5


On macOS you can see all system-set tcp values with

$ sysctl net.inet.tcp

Interpreted from tcp_var.h, tcp_subr.c, and tcp_timer.c:

  • net.inet.tcp.keepidle = keepalive idle timer
  • net.inet.tcp.keepintvl = interval to send keepalives
  • net.inet.tcp.keepinit = timeout for establishing syn
  • net.inet.tcp.mssdflt = Default TCP Maximum Segment Size
  • net.inet.tcp.v6mssdflt = Default TCP Maximum Segment Size for IPv6
  • net.inet.tcp.minmss = Minmum TCP Maximum Segment Size
  • net.inet.tcp.minmssoverload = Number of TCP Segments per Second allowed to be under the MINMSS Size
  • net.inet.tcp.rfc1323 = Enable rfc1323 (high performance TCP) extensions
  • net.inet.tcp.rfc1644 = Enable rfc1644 (TTCP) extensions
  • net.inet.tcp.do_tcpdrain = Enable tcp_drain routine for extra help when low on mbufs
  • net.inet.tcp.pcbcount = Number of active PCBs
  • net.inet.tcp.icmp_may_rst = Certain ICMP unreachable messages may abort connections in SYN_SENT
  • net.inet.tcp.strict_rfc1948 = Determines if RFC1948 is followed exactly
  • net.inet.tcp.isn_reseed_interval = Seconds between reseeding of ISN secret
  • net.inet.tcp.background_io_enabled = Background IO Enabled
  • net.inet.tcp.rtt_min = min rtt value allowed
  • net.inet.tcp.randomize_ports = Randomize TCP port numbers
  • net.inet.tcp.tcbhashsize = Size of TCP control-block hashtable
  • net.inet.tcp.msl = Maximum segment lifetime
  • net.inet.tcp.always_keepalive = Assume SO_KEEPALIVE on all TCP connections
  • net.inet.tcp.broken_peer_syn_rxmit_thres = Number of retransmitted SYNs before TCP disables rfc1323 and rfc1644 during the rest of attempts
  • net.inet.tcp.pmtud_blackhole_detection = Path MTU Discovery Black Hole Detection
  • net.inet.tcp.pmtud_blackhole_mss = Path MTU Discovery Black Hole Detection lowered MSS

I believe by default 8 keepalives will be sent before the connection is closed if SO_KEEPALIVE is set. Times are in milliseconds.


For linux you can use:

$ sysctl -a | grep net.ipv4

I'm not sure if this is what you're looking for, but you can check the keep-alive value with:

$ netstat -o
  • 5
    netstat doesn't accept the '-o' option for me in Mac OS X 10.6.6
    – fuzzyTew
    Commented May 31, 2011 at 11:54

Maybe unrelated, but works for me:

I'm trying to determine the ssh/tcp interactive timeout to one of our servers, so i just:

date; ssh host.domain 'sleep 10000'; date

example output:

Thu May 24 12:22:39 CEST 2018
packet_write_wait: Connection to port 22: Broken pipe
Thu May 24 14:22:40 CEST 2018
  • You could do that using time, like: time ssh hostname 'sleep 10000'
    – Luciano
    Commented Aug 26, 2020 at 12:07

On Linux, the initial timeout for establishing a TCP connection is not configured as a value in seconds. Instead, there's a hardcoded initial RTO (Retransmission TimeOut) of 1 second and a configurable number of retries (with exponential back-off). To quote the kernel docs:

tcp_syn_retries - INTEGER
Number of times initial SYNs for an active TCP connection attempt will be retransmitted. Should not be higher than 127. Default value is 6, which corresponds to 63seconds till the last retransmission with the current initial RTO of 1second. With this the final timeout for an active TCP connection attempt will happen after 127 seconds.

Reportedly, the specific default value can vary depending on the distribution. You can cat /proc/sys/net/ipv4/tcp_syn_retries to see the currently configured value.

If you're using systemd-sysctl.service, you can override this by creating a file in /etc/sysctl.d/*.conf, e.g.:

sudo bash -c 'echo "sys.net.ipv4.tcp_syn_retries = 4" >> /etc/sysctl.d/local.conf'
sudo reboot

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .