Yes, both can contribute to the problem.
A database server has a limit on how many simultaneous connections it can handle. When that limit is reached, new connection requests may be rejected until existing connections are closed.
On a WordPress website, this can happen because of heavy traffic, inefficient plugins, repeated database queries or background tasks running too frequently.
I'd recommend checking your database usage and asking your hosting provider whether your account is reaching its connection limit.
If you're using WordPress, review recently installed plugins and check whether any of them are generating excessive database requests.
You should also make sure your caching system is configured properly. Page caching can reduce unnecessary database queries for visitors.
Don't immediately increase database connection limits without investigating the cause. More connections require more server resources, and simply increasing the limit may not solve the underlying problem.