SQLSTATE[HY000] [2002] No such file or directory

I installed some days ago Magento 2.3.5 in a VPS with a CentOS Linux 7.8.2003 and Plesk.
Once was installed I was try to start the crontab with a SSH can’t do it.
/var/www/vhosts/mydomain.com/subomain.mydomain.com -bash-4.2$ bin/magento cron:install Magento supports PHP 7.1.3 or later. Please read https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html-bash-4.2$

I was expect that’s an issue because I have an older PHP release in mydomain.com and Magento is installed in a subdomain folder inside, a hierarchy down level?

After I contact with my hosting support they said I need to start the crontab form a cronjob in Plesk, just typing some examples, finally I compose one:
/opt/plesk/php/7.3/bin/php /var/www/vhosts/mydomain.com/subdomain.mydomain.com/bin/magento my domain.com/subdomain.mydomain.com/bin/magento cron:run 2>&1

It’s correct typing 2>&1 what’s meaning ?

Whatever cronjob up and start to work but returns an error:

In Abstract.php line 144:

 SQLSTATE[HY000] [2002] Connection refused  


In Abstract.php line 144:

 SQLSTATE[HY000] [2002] Connection refused  


In Abstract.php line 128:

 SQLSTATE[HY000] [2002] Connection refused  


queue:consumers:start [--max-messages MAX-MESSAGES] [--batch-size BATCH-SIZE] [--area-code AREA-CODE] [--single-thread] [--pid-file-path PID-FILE-PATH] [--] <consumer>
In Abstract.php line 128:


 SQLSTATE[HY000] [2002] Connection refused  


queue:consumers:start [--max-messages MAX-MESSAGES] [--batch-size BATCH-SIZE] [--area-code AREA-CODE] [--single-thread] [--pid-file-path PID-FILE-PATH] [--] <consumer>

In Abstract.php line 144:

 SQLSTATE[HY000] [2002] Connection refused  


In Abstract.php line 128:

 SQLSTATE[HY000] [2002] Connection refused  


In Abstract.php line 144:

 SQLSTATE[HY000] [2002] Connection refused  


queue:consumers:start [--max-messages MAX-MESSAGES] [--batch-size BATCH-SIZE] [--area-code AREA-CODE] [--single-thread] [--pid-file-path PID-FILE-PATH] [--] <consumer>

In Abstract.php line 128:

 SQLSTATE[HY000] [2002] Connection refused  


queue:consumers:start [--max-messages MAX-MESSAGES] [--batch-size BATCH-SIZE] [--area-code AREA-CODE] [--single-thread] [--pid-file-path PID-FILE-PATH] [--] <consumer>

It’s a wrong configuration ? It’s a MySQL memory ? Do I need upgrade something in cronjob ?

Thank you in advance, Juan

I don’t use Plesk. When I tried it many years ago, it made my life miserable because it was so hard to change everything - Therefore, I can’t offer you much help as I obviously don’t know how to use it properly myself.

However, here are some responses to your post:

  • If you installed Magento 2.3.5 from scratch yourself, then the cronjobs should have been installed as part of the installation script automatically.
  • Explanation for >/dev/null 2>&1 can be found here. More information on setting up cronjobs can be found in the Official Magento Documentation.
  • You error makes me think that the Database Credentials are either a) incorrect b) MySQL port is blocked c) MySQL has stopped (which are all unrelated to cron)

As I mentioned, your Plesk environment has too many unknowns for me to narrow down your issues as it introduces variables that I may not have considered.

I forget to mention that a few days ago, I tried to solution the issue of this post, editing the next file: /app/etc/env.php and I changed 127.0.0.1 instead localhost
but nothing get better.

Have sense that you said about incorrect credentials or MySQL port blocked. The MySQL stopped isn’t possible because I can search in Magento customer view and get product results. Well this make me think if it’s possible have wrong credentials or port blocked and works fine in the customer view?
Whatever I will go deeply and let you known…
Personally I do not like the response when typing a command in SSH and Magento reply > Magento supports PHP 7.1.3 or later.
I just execute once the next command from cronjob:
/opt/plesk/php/7.3/bin/php /var/www/vhost/mydomain.com/subdomain.mydomain.com/bin/magento setup:upgrade

let’s see what happens, I will let you known…

I think is solved, before when I executed the cronjob from plesk, cron run never reply a successfull report and now it is. They reply a successful in 2 seconds.

That’s gorgeous.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.