cancel
Showing results for 
Search instead for 
Did you mean: 

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Please can someone help, I am tearing out what little hair I have left.

I had to move a clients Magento from one 1and1 server to another and am getting the above error message when trying to access the site. Whilst 1and1 server support have tried to be helpful their Magento knowledge is limited and I am not getting very far.

Initially I was told to just upload the Magento files and database to the new server after which I was getting the above error report. After three days of trying to get help at 1and1 someone said that I should have installed Magento first through Plesk and then uploaded the files. I duly did this and prior to uploading the original files Magento was actually working with the basic installation page and I could get access to Admin but after uploading the files and the database I am back to square one.

I have checked over and over again the local.xml with the settings in Plesk and as far as I can see the database settings are correct.

Please can someone help as I have a client who is quickly losing patience and to be honest I can't blame him!

8 REPLIES 8

Re: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Hi @garynb,

 

Can you check your database credentials?

Maybe your current configuration is trying to access to an old remote database server?

Re: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Thanks Damian

Other than the local.xml file which I know is correct is there anywhere else to check?

Re: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

You are lookign the right file.

Also you'll need to clear cache.

 

Are you being able to connect to the database using the credentials placed on your file but using the command line?

Re: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Thanks again Damian

Yes I had cleared the cache and all sessions.
I haven't tried connecting from the command line so will do that in the morning.
I have a feeling that I may not have imported the database correctly so will try that again.
Originally I moved the site by uploading the files and database to the new server and had the same database error message. 1and1 suggested that I install Magento first via Plesk and then upload the files and database which I did. The one thing that bothered me is that the version of the new install is later than the original site. 1and1 said that didn't mattter but I'm not so sure. Also a new install creates a new database which I had to drop and import the original which in my mind is messy.
In your opinion do you think it's ok just to upload the files and database without the need of a fresh Magento install?
Gary

Re: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Hi Damian

Tried connecting database using ssh and that worked fine. Listed all tables.

So must be a Magento problem somewhere

Gary

 

Re: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Hi @garynb,

 

On Magento 1, normally, th eonly place to find database credentials is /app/etc/local.xml

Maybe you can check the file and credentials?

Can you perform an search through your files looking for the old user or password? (Maybe can be hardcoded at some place?)

Re: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Hi Damian

Finally cracked it. When I updated the local.xml file I renamed the original one localold.xml as I've done hundreds of times just to keep the original. I eventually found out that Magento reads all the .xml files in the app/etc folder whatever the file name. I deleted the localold.xml and hey presto the site appeared. Can't believe I spent days on this just for that.
Thank you again for your help.
Gary

Re: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known

Great!

 

That's because Magento reads all the *.xml files into that directory.

Your original file was being read after (because the name) and the credentials were overwritten.

 

Extra files has something like *.xml.additional so those files won't be used. On Enterprise versions you'll find a file called enterprise.xml too.

 

(I've learned that in the hard way too, you're not alone here)