Error 500 when trying to add a vhost via the API

I have a WordPress multisite installation with subdomains. Upon new site initialization, I am using the API to add the relevant vhost (subdomain) and enable LE. Namely:

1. v-add-web-domain user sub.domain.com XX.XX.XX.XX
2. v-change-web-domain-docroot user sub.domain.com domain.com
3. v-add-letsencrypt-domain user sub.domain.com
4. v-add-web-domain-ssl-force user sub.domain.com
5. v-add-web-domain-ssl-hsts user sub.domain.com

When this sequence runs, I get a 500. After that, the web domain is properly created, its docroot is changed, the certificate is in-place but neither SSL force nor HSTS are enabled.

The problem is definitely in step #3 (add LE) because the function that makes the call never finishes. Also, when I run the above as a CLI batch script, everything works as expected.

domain.com.error.log says:

[proxy_fcgi:error] [pid] [client] AH01067: Failed to read FastCGI header, referer: https://domain.com/wp-admin/network/site-new.php
[proxy_fcgi:error] [pid] (104)Connection reset by peer: [client] AH01075: Error dispatching request to : , referer: https://domain.com/wp-admin/network/site-new.php

v-add-letsencrypt-domain probally reloads nginx/apache2 causing the issue

Probably? You mean there’s a setting I can change somewhere? Because the API call doesn’t seem to support a parameter for that…
Also, does it do that via the API and not via CLI?