I have a multi-site setup and toggled the primary site inside settings -> sites to "off". So now I don't have any primary site anymore and I get an error preventing me from accessing my admin page saying: "craft\errors\SiteNotFoundException: No primary site exists in xyz". How can I redefine a primary site?


Try to change the primary field, from 0 to 1, in the craft_sites DB table.


This doesn't directly solve the OP's issue, but related:

$site = Craft::$app->sites->getSiteByHandle('mySite');
$site->primary = true;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.