Good practice : localhost or 127.0.0.1 ?

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Good practice : localhost or 127.0.0.1 ?

Post by bangkok » Thu Nov 10, 2011 6:44 pm

On a windows XP machine, with MySQl server and a livecode stack connecting to the mysql server, what is the best :

to use "localhost" or "127.0.0.1" ?

Or there is absolutely no difference ?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Good practice : localhost or 127.0.0.1 ?

Post by mwieder » Thu Nov 10, 2011 6:58 pm

There's *almost* no difference. The "localhost" designation will use the hosts file on your computer to resolve that and come up with 127.0.0.1, so in that case you get the same result. However, you could edit your hosts file to redirect localhost somewhere else (I can't think of a use case for this, but just sayin') and then you'd get a different result. There are also some malware apps floating around that rewrite your hosts file and cause all kinds of havoc until you fix things up. If your computer gets messed up this way you'll probably have bigger problems to worry about than whether you should use one designation or the other.

So basically there's no difference and you can use either one. Note, though, that you can't mix them in LiveCode scripts: if you open a port to "localhost" and then try to access it as "127.0.0.1" it won't work - you have to be consistent.

Post Reply