NetworkSetup -setdnsservers Did not work

I have used command below in Terminal:

networksetup -setdnsservers Wi-Fi ...

But return:

** Error: Unable to commit changes to network database.

I try add sudo before command, but the result is still the same.

How can I fix this?



MacBook Air (M2, 2022)

Posted on Mar 25, 2025 06:40 PM

Reply
3 replies

Mar 27, 2025 09:21 AM in response to zeyu32

By any chance did you rename your network interface? We are assuming you are using the default name of Wi-Fi. Try running this command:


networksetup -listallnetworkservices


Do you see Wi-Fi listed?


Next, if you really think the network settings are a mess, and you can easily recreate everything, you can trash the network config plist, reboot, and start over. The file you want to trash is:


/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist


Save all you work, move that file to the Trash and immediately reboot the machine. On reboot, the system will poll the available hardware and reconstruct the NetworkInterfaces.plist file.


Hope this helps





This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

NetworkSetup -setdnsservers Did not work

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.