Member-only story
Mac: Set Maximum Connection and Port Parameters
Maximum Connections Limit
The maximum number of connections limit refers to the limit of the maximum number of files (file descriptors) that the system can open, which is divided into global and per-process types:
Global
## The system's default maximum number of connections limit is 2147483647
$ sysctl kern.maxfiles
kern.maxfiles: 2147483647
## Set the system's maximum number of connections from 49152 to 1048600
$ sudo sysctl -w kern.maxfiles=1048600 Per-Process
# The default maximum number of connections per process is 61440
$ sysctl kern.maxfilesperproc
kern.maxfilesperproc: 61440
# Set the per-process connection limit from 24576 to 1048576, the maximum number of connections per process must be less than or equal to the global connection limit
$ sudo sysctl -w kern.maxfilesperproc=1048576 To make permanent changes, add the following content to /etc/sysctl.conf
kern.maxfiles=20480
kern.maxfilesperproc=18000This file may need to be created manually.
Ulimit Command
$ ulimit -n 4864 #### Display the maximum number of files that the current shell can open, the default value is: 4864, this value is always…
