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?

2 Answers 2


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 and acknowledge you have read our privacy policy.