What is Localhost?
“localhost” describes a communication port connecting to the origin server. It allows you to spoof network connections when such a network does not or does not exist, by allowing a network connection to loop back on itself. In practice, localhost is considered a synonym for 127.0.0.1 for use and discussion. However, it is important to remember that they are not exactly the same.
What is 127.0.0.1?
127.0.0.1 is the most commonly used loopback IP address. It's part of a reserved block of over sixteen million IP addresses used specifically for loopback functionality. Loopback allows your computer to communicate with itself while using network connection protocols.
How localhost differs from 127.0.0.1?

On most machines localhost and 127.0.0.1 are functionally the same. But localhost is a label for the IP address, not the address itself. Different IP addresses of localhost can be pointed to. In fact, it can be pointed at any IP address, even outside the reserved address block. The HOST file doesn't care and doesn't stop you. However, it will break essential functionality on your system and crash any application that relies on a local area connection.
Address block 127 was chosen for the loopback address block because it was the last block of Class A addresses operating from the binary address value 00000001 to 01111111. In IPv6, the loopback address is the first address 0:0:0. : 0: 0: 0: 0: 1 is most often expressed in truncated form as ::1.
If you're coming from Windows to a Unix system, you may have noticed that fallback is practically synonymous with localhost. You could use your HOST file to have the fallback redirect to 127.0.0.1, but that's more of a text replacement than anything else.
So, how you see the differences between them?