Back up all data before proceeding.
Sometimes the Wi-Fi icon in the menu bar may falsely indicate that Wi-Fi is unavailable. That could happen if you switch between network locations, one of which doesn't have a Wi-Fi service.
Open the Network pane in System Preferences. A list of available network services appears on the left. If Wi-Fi is in the list, select it, then from the popup menu labeled with a gear icon at the bottom of the list, select
Make Service Active
Click Apply.
If Wi-Fi is not in the service list, click the plus-sign button at the bottom of the list, and then select Wi-Fi from the Interface menu in the sheet that drops down. Click Create, then Apply.
If there is a closed padlock icon in the lower left corner of the preference pane, click it and enter your administrator password to unlock the settings.
If the above steps don't solve the problem, continue.
Triple-click anywhere in the line below on this page to select it:
/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist
Right-click or control-click the line and select
Services ▹ Reveal in Finder (or just Reveal)
from the contextual menu.* A folder should open with "com.apple.airport.preferences.plist" selected. Move the selected item to the Trash. You may be prompted for your administrator password. Restart the computer and recreate your settings for Wi-Fi in the Network preference pane.
*If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
Go ▹ Go to Folder...
from the menu bar and paste into the box that opens by pressing command-V. You won't see what you pasted because a line break is included. Press return.