There are few things that strike as much fear into the hearts of Mac users as the dreaded flashing folder with question mark in the middle of the screen on startup. That's a signal that your Mac is unable to find its startup disk and so unable to boot.
The reasons for that range from the relatively benign (you've previously started up from an external disk and unplugged it) to the more serious (your Mac's hard drive has failed catastrophically). Whatever the cause, you'll find advice and fixes to help in the following article. Read next: How to fix a Mac that won't turn on
Put your Mac in Recovery mode
Assuming you're trying to boot from your Mac's internal drive, the first thing to do is shut down the Mac by holding down the power button, then start up while holding the Command and R keys until you see an Apple logo or globe. This puts your Mac in recovery mode.
From here, you can change the startup disk by selecting Startup Disk from the Apple menu.
Repair the disk
If you can't see your startup drive, open Disk Utility from the macOS Utilities window. Click on your startup drive and click the First Aid tab. Click Run.
If the repair completes successfully, you can select the disk in Startup Disk in the Apple menu and restart.
If the repair fails or you can't see your startup disk in Disk Utilities, you'll need to erase the disk and reinstall macOS.
Back up your data
If you've got a recent Time Machine backup, select Restore from Time Machine Backup in the macOS Utilities window.
If you haven't got a backup, you'll need to make one.
Plug in a spare external drive and open Disk Utility. Click the Erase tab and erase the external drive. When it's done, select Reinstall macOS from the Utilities window and make sure you select the external disk you just erased.
Follow the instructions and wait for your Mac to reboot. When you see the Setup Assistant, choose the option to migrate data from another Disk and select your Mac's regular startup disk.
Complete the Setup process and wait for your Mac to finish. When it's done, confirm your data is on the external drive.
Erase your startup disk and reinstall macOS
You can now erase your Mac's regular startup drive in Disk Utility. Boot in recovery mode again, from the external disk, and choose Reinstall macOS, this time selecting your Mac's original startup drive. When it's done and your Mac has restarted, choose the migrate data option again and this time choose the external drive as the source for the data you want to move.
When that's done, you should have a fresh install of macOS on your startup drive with all your data intact.
If all else fails, consult a Genius
If none of the above works, your drive may have a hardware fault. The best course of action then is to make an appointment with a Genius at your nearest Apple Store and ask for help.