mysql host address problem - 127.0.0.1 instead of localhost

AgoraHosting

Verified User
Joined
Apr 7, 2004
Messages
12
Hello, we have a strange problem that we couldn't understand the source...

Our mysql service is running properly and users' databases can be accessible from local websites and from remote. However when local websites tries to access using "localhost" they can not connect. If we use "127.0.0.1" instead of "localhost" it works!

When I ping localhost or nslookup localhost, I get the IP: 127.0.0.1

As most of the scripts and DA uses localhost instead of typing 127.0.0.1, we receive many trouble tickets.!!!

How can we solve this problem? Please help...
 
DirectAdmin should be setting up the databases to use localhost by default, at least on my server it does.
You can add localhost to the list of hosts allowed to access the database in the MySQL managment page. Click on the database you want to modify. The tool is on the bottom of that page.
 
Yes, it is setting up the database to use localhost by default.
It gives this information after creating the database.

localhost is also found on the tool you have specified. But when you use localhost as the mysql host on php files for example PHPBB config.php files, it makes the mysql db inacessible to the database.

Can there be another problem?
 
As we can not access mysql databases using "localhost" we can configure scripts to use "127.0.0.1"

But we can not use PhpMyAdmin because it is configured to use "localhost" by default.

We are sure that all databases are configured to use localhost by default... We tried adding new mysql dbs using DA and at the end of creation DA gives us the DB Host name as "localhost"

Please help :(
 
Verify that localhost is in the /etc/hosts file. The first few lines should look like this:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost localhost.localdomain

When you ping localhost or nslookup local host, you are looking in the dns records, and it is finding the information in the localhost.zone file. When a php application tries to resolve localhost, it will look in the /etc/hosts file only (since no domain name was specified) and fail.
 
Yes that line exists as the first line.
Nslookup was also able to find 127.0.0.1 as localhost's IP address.

I made a clean php installation and that fixed the problem.
Thank you.
 
We're finding some of the same symptoms you are on a CentOS system. What OS are you using, AgoraHosting?



Exactly what did you do to get a clean PHP installation?

Thanks.

Jeff
 
I'm running a server on centos 3.3 without any issues. I only had to yum install gcc and g++ before the DA installer would run.

Phi1.
 
Thanks, Phil. Our testbed is currently also running CentOS (the latest).

I'm not sure yet we're having a problem; I need someone with time to try installing a domain and a database (and software to use the database) for me to see if it runs.

Have the time?

Jeff
 
Hi,

I just followed one of a an instruction of Direct Admin Support (John) that I found in one of the threads.

When I did the clean php installation the problem got resolved.
 
Thanks for the suggestion. I've got a volunteer to install a new site on the testbed server with a php-based forum, if necessary for testing. We're not yet sure what the problem is; it's something that came up during our experiments to create a restore system for the DA (sysbk) backup.

Jeff
 
i have the same problem,

i can connect all db by 127.0.0.1
but not localhost

its same for phpmyadmin

cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost

[root@box2 virtual]# ping localhost
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=2 ttl=64 time=0.016 ms


so what is the problem??

i dont touch nothing, DIRECTADMIN make the install on this one

and cannot work with localhost..

just not funny, i buy a new directadmin , and they install me a broken version..
 
duke27 said:
i have the same problem,

i can connect all db by 127.0.0.1
but not localhost

its same for phpmyadmin

cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost

[root@box2 virtual]# ping localhost
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=2 ttl=64 time=0.016 ms


so what is the problem??

i dont touch nothing, DIRECTADMIN make the install on this one

and cannot work with localhost..

just not funny, i buy a new directadmin , and they install me a broken version..

When creating a mysql user, you must specify "from localhost" if you want your users to be permitted to connect. Selecting "from anyhost" is not the same thing. Log into phpMyAdmin with the root or admin account, and create the same user name with the same permissions as before, but select "localhost" as the host name.
 
Back
Top