Jump to content

[SOLVE] - Digital Ocean Migration -v1.7.7.2 - Link to database cannot be established: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known


Recommended Posts

Hi everybody,

 

I've just started migrating my Prestashop from Ionos 1&1 to Digital Ocean Vps.

 

But I'm having an issue, when I try to connect to my website with my public ip adress of my Vps, it doesn't work.

 

It show me an error 500 and in the logs i've got this :

 

*ERROR*     v1.7.7.2    Link to database cannot be established: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known at line 136 in file classes/db/DbPDO.php

 

Here is my parameters.php file :

<?php return array (

  'parameters' => 

  array (

    'database_host' => 'localhost',

    'database_port' => '',

    'database_name' => '[thenameofmydatabase],

    'database_user' => '[thenameofmyuser]',

    'database_password' => '[thepassword]t',

    'database_prefix' => 'miib_',

    'database_engine' => 'MySQL',

    'mailer_transport' => 'smtp',

    'mailer_host' => '127.0.0.1',

    'mailer_user' => NULL,

    'mailer_password' => NULL,

    'secret' => '[itsasecret]',

    'ps_caching' => 'CacheMemcache',

    'ps_cache_enable' => false,

    'ps_creation_date' => '2021-01-11',

    'locale' => 'en-US',

    'use_debug_toolbar' => true,

    'cookie_key' => '[itsasecret]',

    'cookie_iv' => '[itsasecret]',

    'new_cookie_key' => '[itsasecret]',

  ),

);

 

I tried many other parameters as replacing my database host by 127.0.0.1, or my server ip adress, I modified my database engine, but I'm not sure it's good

I tried with and without the 3306 port and even with all of that it doesn't work.

 

I've already tried to insert a big error in my parameters.php file to see if it was read and it is.

My phpAdmin Panel is saying this :

 

 

Apache/2.4.41 (Ubuntu)

Version du client de base de données : libmysql - mysqlnd 7.4.3

Extension PHP : mysqli curl mbstring

Version de PHP : 7.4.3

 

Serveur : Localhost via UNIX socket

Type de serveur : MySQL

Connexion au serveur : SSL n'est pas utilisé 

Version du serveur : 8.0.23-0ubuntu0.20.04.1 - (Ubuntu)

Version du protocole : 10

Utilisateur : secret

Jeu de caractères du serveur : UTF-8 Unicode (utf8mb4)

 

I really need some help

 

I'm asking myself that :

 

Maybe issue is coming directly from my ps_domain information in my database, even if I've already modified it, but if my ps_domain was wrong, should the database could connect and the error would be an other one ?

 

Or other possibility, my database_engine informations is wrong, how can I verify this ?

 

Then, how can I found my database_host because the issue seems to be coming from this.

 

I've already grant permissions on the user that I'm trying to connect to the database.

 

I've setup my server following these tuto :

 

 

Initial Server Setup for Ubuntu

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04

 

Install LAMP on Ubuntu

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-14-04

 

Install phpmyadmin on Ubuntu

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-16-04

 

For version 20.04

 

I really need help on this

Edited by jmauclair
solve (see edit history)
Link to comment
Share on other sites

Hi,

 

Thanks for your answer, just resolve every issues ^^

 

So I had to remove the prod and dev cache, then Downgrade my php version (to 7.2) and then modify mysql auth_socket plugin to mysql native password because mysql older versions doesn't support sha2

 

By the way, I change my whole www repertory to 777 permissions, that what solve most of the issue

Edited by jmauclair (see edit history)
Link to comment
Share on other sites

  • jmauclair changed the title to [SOLVE] - Digital Ocean Migration -v1.7.7.2 - Link to database cannot be established: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
2 hours ago, Crezzur said:

Please do not change your whole WWW folder structure to 777 this causes alot of security issues.

Its better to change it to 775 (folders) and 664 (files)

Yes I know, but right now it's the only fix that I found, when I try to change, even in 775, it cause error 500 issue

Link to comment
Share on other sites

Just now, Crezzur said:

Error 500 --> enable your debug modus and it will explain what the issue is.

I'd love to enable the debug mode but last it caused me a really big issue and we are currently on a marketing campaign, so I'll try when we will be out of the campaign, I don't want my fresh customers to be sad to see a big and nice php error ;) 

Link to comment
Share on other sites

On 3/12/2021 at 8:29 AM, Crezzur said:

Please do not change your whole WWW folder structure to 777 this causes alot of security issues.

Its better to change it to 775 (folders) and 664 (files)

After investigating, it seems that my prestashop isn't set as root user for my db.

 

Do you know how can I do that ? You seems to be better in this than me :) 

 

By the way my debug is working, not perfectly because sometime (usually when I delete the cache) I've got an error 500 that pop and no error message as the debugger should display

Edited by jmauclair (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...