ulimit -n shows different values in mac terminal and intellij terminal
The problem is caused by IntelliJ being a Java program that is subject to the constraints of the Java virtual machine, which by default on macOS is set to limit the number of open files to 10240 - no matter which setting is used elsewhere in the operating system.
The solution is as follows:

Add -XX:-MaxFDLimit in IntelliJ Idea (Help-&gt;Edit Custom VM options)
Invalidate cache and restart IntelliJ

This removes the arbitrary 10240 limit on the Java virtual machine, and makes it so that IntelliJ is instead only limited by the general macOS open files limit - like any other program.