Safari can't connect to localhost I'm trying to use Focus, an app that redirects blocked websites through localhost. However, while this works properly with Chrome and Firefox, Safari gives me an error message as in the attached image.

If in the web address I replace localhost with 127.0.0.1 everything works fine. How can I fix this?

The content of my /private/etc/hosts file is the default one, i.e.

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost




EDIT: Here is a screenshot of my proxies.
Edit: this didn't help, ignore it.

This might be related to HSTS. Different browsers deal with it in different ways. Do you have any non-Apache local web server installed? I'm assuming there's something to do with Focus that's running on port 8919 from your screenshot.

Try this: Quit Safari, make a backup of ~/Library/Cookies/HSTS.plist somewhere safe, delete ~/Library/Cookies/HSTS.plist, start Safari, and try that URL again. Does that help?