I have this exact same problem!
Tried the solution from Carolyn Samit and managed to get to the facebook login page but as soon as i entered my u/name & password i was redirected to the same error message ;-
Safari cant open the page https://www.facebook.com/login.php?login_attempt=1 because Safari cant connect to the server www.facebook.com
I have updated my Mac to the latest everything including operating system, updated the router (Sky), restarted everything and tried the solution above and nothing helps!
I have tried every other website in my favourites and they all work fine.
The only remotely related issue is that i get similar error messages when i enter a search in the web address bar at the top of the screen - this used to automatically perform a google search but no longer works.
Has been like this for a few weeks now and is starting to get annoying.
Any help will be much appreciated.
I did have the same problem too and the only thing that worked for me was resetting the DNS, thanks to the comment of AndyBall_UK (see above).
You can follow directions here: