Introduction / Why This Is Needed
A network issue on macOS can manifest in various ways: complete lack of connectivity, low speed, connection drops, or inability to resolve domain names. This guide offers a systematic, from simple to complex, algorithm for diagnosing and restoring network functionality without reinstalling the system. You will learn to use macOS's built-in tools to precisely locate the problem.
Requirements / Preparation
Before starting, ensure that:
- You have administrator rights on the computer (some
sudocommands will require them). - You know the administrator password.
- The router/modem you are connecting to is functional and works with other devices.
- For a wired connection, check the cable and the router's port.
Step 1: Checking Physical Connection and Basic States
This is the first and most crucial stage, eliminating external factors.
- Check the Wi-Fi indicator in the menu bar. It should be lit. Click on it and ensure your network item is active and the "Turn Wi-Fi Off" checkbox is not selected.
- For a wired connection (Ethernet), check if the indicator light is on on both the MacBook's port and the router.
- Restart the router (unplug it for 30 seconds, plug it back in) and after the router has fully booted, restart the Mac.
- Try connecting to a different network (e.g., a phone's hotspot). If everything works on another network — the problem is with your router or its settings.
Step 2: Configuration Analysis via Terminal
Accurate diagnosis begins with understanding what the system "sees".
- Open Terminal (Applications → Utilities).
- Type the command
ifconfigand press Enter. - Find the interface that should be active in the output:
en0— usually Wi-Fi.en1,en2— additional or Ethernet ports.pdp_ip0,pdp_ip1— cellular internet (if available).
- In the line for this interface, find
inet. If an address is listed (e.g.,inet 192.168.1.105), it means the Mac has received an IP address from the DHCP server (router). Ifinetis missing, no IP was issued.
# Example output for active Wi-Fi (en0)
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether xx:xx:xx:xx:xx:xx
inet6 fe80::aede:48ff:fe00:1122%en0 prefixlen 64 secured scopeid 0x4
inet 192.168.1.105 netmask 0xffffff00 broadcast 192.168.1.255
# ... other lines
Step 3: Pinging the Gateway and External Addresses
Pings will help determine where the connection breaks.
- Identify the gateway. The simplest way is to go to System Settings → Network → Your Connection → Details → TCP/IP. The "Router" field is the gateway.
- In Terminal, execute:
(e.g.,ping <gateway_ip>ping 192.168.1.1). If the ping succeeds (lines like64 bytes from...appear), communication with the local network exists. - If pinging the gateway works, ping a public address:
ping 8.8.8.8- If pinging
8.8.8.8works, but sites don't open in the browser — the problem is likely with DNS resolution (see Step 4). - If pinging
8.8.8.8does NOT work — the issue is at the network channel, routing level, or the router has no internet access. Return to Step 1.
- If pinging
Step 4: Checking and Changing DNS Servers
Incorrect or slow DNS servers lead to errors like "Server not found for example.com".
- Go to System Settings → Network.
- Select the active connection (Wi-Fi or Ethernet) and click "Details...".
- Go to the DNS tab.
- Remove all existing servers by clicking "-".
- Click "+" and add public DNS servers:
8.8.8.8(Google)1.1.1.1(Cloudflare)
- Click "OK" and "Apply".
Step 5: Flushing DNS Cache and macOS Services
The macOS system caches DNS queries. After changing DNS servers, the cache needs to be cleared.
- In Terminal, execute the commands one after another:
(You will enter your password; characters will not be displayed).sudo dscacheutil -flushcache - Then:
This command restarts the name resolution service. In modern macOS versions (Mojave and newer), this is the primary method.sudo killall -HUP mDNSResponder
Step 6: Removing and Re-adding the Network Interface
Corrupted preference files can interfere. Deleting the service will force macOS to recreate it.
- In System Settings → Network, select the service list on the left (e.g., Wi-Fi).
- Click the "-" button at the bottom of the list. Confirm the deletion.
- Click the "+" button. In the window that appears, select the interface (e.g., Wi-Fi) and create it.
- Click "Apply".
- For Wi-Fi, you will need to select the network again and enter the password.
Step 7: Creating a New Network Location
This is an extreme but effective way to reset ALL system network settings to "default".
- In System Settings → Network, at the top of the window, use the "Location" dropdown menu.
- Click "Edit Locations...".
- Click "+" and create a new one (e.g., "Home-Clean").
- Select the new location. The system will restart all network services "from scratch". Configure Wi-Fi/Ethernet again.
Verifying the Result
- Open your browser and try loading several websites.
- In Terminal, run
ping 8.8.8.8. You should see responses without loss (0% packet loss). - Check your speed on
speedtest.netor a similar service. The values should be close to your plan's advertised rates.
Potential Issues
sudo: dscacheutil: command not found: Thedscacheutilcommand is deprecated in recent macOS versions. Skip it and only runsudo killall -HUP mDNSResponder.- No administrator rights: Some commands (
sudo) require an administrator password. Ensure you are logged into an account with admin privileges. - After reset, Wi-Fi doesn't see networks: Ensure the "Show network" option is enabled in Wi-Fi settings (Step 6). If the problem persists, try a full NVRAM/PRAM reset (key combination
Option+Command+P+Rduring Mac startup). - Problem only with one network: If everything works on all networks except one, the issue is with that specific network's settings (router filters, incorrect password, MAC address restriction).
- Error "Failed to obtain IP address" appeared: Check if the DHCP pool on the router is exhausted. Try setting a manual IP address in network settings (Details → TCP/IP → "Using DHCP with manual address").