This question already has an answer here:
After the recent upgrade to macOS Mojave Safari started redirecting from
https://localhost. The problem persists only in Safari, in Chrome everything is the same as before. Now I'm temporary using
127.0.0.1 as a replacement, but it's inconvenient due to some limitations of software I'm using.
I tried searching and found some similar questions, where accepted answers were to kill Safari and remove
~/Library/Cookies/HSTS.plist file, and in my case it didn't work.
I also tried this answer, without luck.