I was in production mode and was getting an error when trying to go back to default mode
run below commands in sequence.
php bin/magento setup:di:compile
php bin/magento setup:upgrade
php bin/magento cache:clean
php bin/magento cache:flush
and then try to det default mode again, it should work now
bin/magento deploy:mode:set default