diff --git a/doc/man-sections/server-options.rst b/doc/man-sections/server-options.rst
index 7a09809..5c1b129 100644
--- a/doc/man-sections/server-options.rst
+++ b/doc/man-sections/server-options.rst
@@ -418,6 +418,9 @@
 --max-clients n
   Limit server to a maximum of ``n`` concurrent clients. Defaults to 1024.
 
+  With a TCP listener, the soft limit on open files is raised up to the hard
+  limit if needed to accept ``n`` clients (not on Windows and macOS).
+
 --max-routes-per-client n
   Allow a maximum of ``n`` internal routes per client (default
   :code:`256`). This is designed to help contain DoS attacks where an
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index ad9f9f4..900b5a3 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/multi.c
@@ -270,6 +270,68 @@
 #endif
 
 /*
+ * Every TCP client takes a file descriptor, and accept() happens before the
+ * --max-clients check: raise the soft limit so that --max-clients is reached
+ * first, or warn if the hard limit does not allow it.
+ */
+static void
+multi_check_nofile_limit(const struct context *t)
+{
+#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE) && !defined(TARGET_DARWIN)
+    bool tcp = false;
+    for (int i = 0; i < t->c1.link_sockets_num; i++)
+    {
+        if (!proto_is_dgram(t->c2.link_sockets[i]->info.proto))
+        {
+            tcp = true;
+            break;
+        }
+    }
+    if (!tcp)
+    {
+        return;
+    }
+
+    /* room for the tun device, the listeners, log, management, scripts... */
+    const rlim_t needed = (rlim_t)t->options.max_clients + 64;
+
+    struct rlimit rl;
+    if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
+    {
+        msg(M_WARN | M_ERRNO, "WARNING: getrlimit(RLIMIT_NOFILE) failed");
+        return;
+    }
+    if (rl.rlim_cur >= needed)
+    {
+        return;
+    }
+
+    const rlim_t old = rl.rlim_cur;
+    rl.rlim_cur = rl.rlim_max < needed ? rl.rlim_max : needed;
+    if (rl.rlim_cur > old)
+    {
+        if (setrlimit(RLIMIT_NOFILE, &rl) == 0)
+        {
+            msg(M_INFO, "NOTE: raised the open files limit from %lu to %lu", (unsigned long)old,
+                (unsigned long)rl.rlim_cur);
+        }
+        else
+        {
+            msg(M_WARN | M_ERRNO, "WARNING: setrlimit(RLIMIT_NOFILE) failed");
+            rl.rlim_cur = old;
+        }
+    }
+    if (rl.rlim_cur < needed)
+    {
+        msg(M_WARN,
+            "WARNING: the open files limit (soft %lu, hard %lu) is too low for "
+            "--max-clients %" PRIu32 ", TCP clients may be refused before --max-clients is reached",
+            (unsigned long)rl.rlim_cur, (unsigned long)rl.rlim_max, t->options.max_clients);
+    }
+#endif /* if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE) && !defined(TARGET_DARWIN) */
+}
+
+/*
  * Main initialization function, init multi_context object.
  */
 static void
@@ -398,6 +460,7 @@
      * Per-client limits
      */
     m->max_clients = t->options.max_clients;
+    multi_check_nofile_limit(t);
 
     m->instances = calloc(m->max_clients, sizeof(struct multi_instance *));
     check_malloc_return(m->instances);
