The problem was caused by:
define('DOMAIN_CURRENT_SITE', 'www.example.com/site3');
define('PATH_CURRENT_SITE', "https://wordpress.stackexchange.com/");
Changing this to:
define('DOMAIN_CURRENT_SITE', 'www.example.com');
define('PATH_CURRENT_SITE', '/site3/');
with a similar change in the wp_blogs
table solved the problem.