In my case, the problem was with ESET Antivirus. The 'Eset Network Access Protection' extension was blocking my localhost access. I just disabled it."
On MacOS (Sequoia) : System Settings > General > Login Items & Extensions > NetworkExtensions > "info icon"