Safari searches instead of connecting to localhost
I solved it.
It was related to the "Startpage" extension. Startpage is a search engine that is supposed to be private. However, it searches from the address bar, and I guess it does not recognize localhost.