works with 127.0.0.1, but not localhost

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Scam Warning
Post Reply
johnny_canuck
Registered User
Posts: 3
Joined: Mon Feb 11, 2019 1:45 am

works with 127.0.0.1, but not localhost

Post by johnny_canuck » Mon Feb 11, 2019 1:53 am

So, I moved my phpBB board from one server to anotherl. Everything works as it shoiuld, but with a quirk I'm hoping someone can help my figure out. Same OS, same flavour of mySQL, same my.cnf, same php.ini...same everything...more or less (the ip addresses for the two machines, are different, obviously).

On the original server, my config.php had

Code: Select all

<?php
// phpBB 3.1.x auto-generated configuration file
// Do not change anything in this file!
$dbms = 'mysql';
$dbhost = 'localhost';
$dbport = '';
...
However, on the new server, the only way I can connect is to change $dbhost to '127.0.0.1'. Works fine...

My hosts file is the same between the two machines, so I can't see that being the route of the problem. And as noted, my.cnf and php.ini are the same...

I suppose I should be happy that it works, but...I'm puzzled as to why this difference has arisen? I know this is more a mySQL than phpBB thing, but given the experience base of phpBB users/admin, thought I'd try here first....

Pointers to the obvious appreciated...

Thanks...

Wirral Talk
Registered User
Posts: 48
Joined: Mon Jun 09, 2014 12:29 am
Location: Wirral, UK
Contact:

Re: works with 127.0.0.1, but not localhost

Post by Wirral Talk » Mon Feb 11, 2019 3:36 am

What platform are they on? Mac/windows/unix

User avatar
warmweer
Registered User
Posts: 2011
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Belt ... well actually Belgium

Re: works with 127.0.0.1, but not localhost

Post by warmweer » Mon Feb 11, 2019 6:04 am

johnny_canuck wrote:
Mon Feb 11, 2019 1:53 am
...

Code: Select all

<?php
// phpBB 3.1.x auto-generated configuration file
// Do not change anything in this file!
$dbms = 'mysql';
$dbhost = 'localhost';
$dbport = '';
...
However, on the new server, the only way I can connect is to change $dbhost to '127.0.0.1'. Works fine...

My hosts file is the same between the two machines, so I can't see that being the route of the problem. And as noted, my.cnf and php.ini are the same...
"https://en.wikipedia.org/wiki/Localhost#Special_cases" wrote:The releases of the MySQL database differentiate between the use of the hostname localhost and the use of the addresses 127.0.0.1 and ::1.
When using localhost as the destination in a client connector interface of an application, the MySQL application programming interface connects to the database using a Unix domain socket, while a TCP connection via the loopback interface requires the direct use of the explicit address.
BTW: time to move to mysqli (and 3.2)
A bug is a feature that hasn't made it to the manual (yet)

johnny_canuck
Registered User
Posts: 3
Joined: Mon Feb 11, 2019 1:45 am

Re: works with 127.0.0.1, but not localhost

Post by johnny_canuck » Mon Feb 11, 2019 12:27 pm

Wirral Talk wrote:
Mon Feb 11, 2019 3:36 am
What platform are they on? Mac/windows/unix
Sorry, my mistake: GNU/Linux.

johnny_canuck
Registered User
Posts: 3
Joined: Mon Feb 11, 2019 1:45 am

Re: works with 127.0.0.1, but not localhost

Post by johnny_canuck » Mon Feb 11, 2019 12:32 pm

"https://en.wikipedia.org/wiki/Localhost#Special_cases" wrote:The releases of the MySQL database differentiate between the use of the hostname localhost and the use of the addresses 127.0.0.1 and ::1.
When using localhost as the destination in a client connector interface of an application, the MySQL application programming interface connects to the database using a Unix domain socket, while a TCP connection via the loopback interface requires the direct use of the explicit address.
Thanks -- that much I knew (more or less), but what puzzles is me is why one machine is using a socket, and the other a TCP connection, when the two machines are largely redundant. I suppose no matter -- so long as 127.0.0.1 works, I can live with the nanosecond degree to which said connections are (in theory) slower than socket connections. I was simply trying to figure out why there was a difference, since the flavour of mySQL is the same on both machines (same OS, smae php, etc...).
BTW: time to move to mysqli (and 3.2)
No doubt, but as is the case for many users, there are so many mods/tweaks/changes to the board(s) I'm running that a simple migration is anything but simple.

User avatar
mrgoldy
Jr. Extension Validator
Posts: 946
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: works with 127.0.0.1, but not localhost

Post by mrgoldy » Tue Feb 12, 2019 11:50 am

https://stackoverflow.com/questions/314 ... is-working

This should give you perhaps some more insight and possibilities as to what caused the issue.
phpBB Studio / ''Proud member of the Studio"

User avatar
AmigoJack
Registered User
Posts: 5523
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: works with 127.0.0.1, but not localhost

Post by AmigoJack » Thu Feb 14, 2019 9:53 am

The comments in PHP's manual to mysqli_connect also share experiences with both values and their differences on multiple platforms. Bottom line is: don't ever assume them being interchangeable.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

Post Reply

Return to “phpBB Discussion”

Who is online

Users browsing this forum: abdu7maan, KevC and 24 guests