Systemd and delay until "Waiting for connections"


We have mongodb-org-server-6.0.5-1.el8.x86_64 installed on Rocky Linux 8.

We have a number of services that are managed by systemd that require access to MongoDB.

What we have noticed is that these services are trying, and failing, to connect on start because MongoDB isn’t “Waiting for connections” yet.

We are using the default mongod.service unit, and all the services that use MongoDB have the following in their unit definitions: mongod.service mongod.service

For example, we see the following 8 second delay between MongoDB starting and it being available to accept connections:

{"t":{"$date":"2023-04-25T11:28:10.311+01:00"},"s":"I",  "c":"CONTROL",  "id":20698,   "ctx":"-","msg":"***** SERVER RESTARTED *****"}
{"t":{"$date":"2023-04-25T11:28:18.191+01:00"},"s":"I",  "c":"NETWORK",  "id":23016,   "ctx":"listener","msg":"Waiting for connections","attr":{"port":27017,"ssl":"off"}}

but the dependent services are trying to connect as soon as the MongoDB service starts.

Is there something we can add to either the MongoDB config or the systemd unit(s) to tell the dependent services to wait until the mongod.service unit will accept connections?

Thanks in advance.