2

I am stuck with getting Drush to work properly on my development server. And I am pretty sure the main reason is linked to not being able to connect to my site database.

My setup is as following:

  • Website: Drupal 7 (7.23) website running on my personal (Synology) NAS, that is in my LAN.
  • PC OS: Windows8
  • Drush: Used the Windows Installer (installed version: 5.8).

Drush got installed and is "partially" working, meaning: I can run some general Drush commands (e.g. drush status) and e.g. download modules. But e.g. enabling modules generates errors, I have less options for clearing cache, etcetera.

I know something is wrong with the Drush (configuration), as I get e.g. the following a warning message:

PDO::___construct(): [2002] No connection could be made because the target machine actively (trying to connect via tcp://127.0.0.1:3306) environment.inc 517

When I want to retrieve a status overview, I get the following:

    Z:\CMV-OpWeg>drush status
    PDO::__construct(): [2002] No connection could be made because the     [warning]
    target machine actively  (trying to connect via tcp://127.0.0.1:3306)
    environment.inc:517
     Drupal version         :  7.23
     Site URI               :  http://default
     Database driver        :  mysql
     Database hostname      :  127.0.0.1
     Database username      :  root
     Database name          :  cmv-opweg
     Default theme          :  garland
     Administration theme   :  garland
     PHP configuration      :  D:\System Utilities\Drush\Php\php.ini
     Drush version          :  5.8
     Drush configuration    :
     Drush alias files      :  C:\Users\BD/.drush/aliases.drushrc.php
     Drupal root            :  Z:/CMV-OpWeg
     Site path              :  sites/default
     File directory path    :  sites/default/files

And with some Drush commands the error:

Drush was not able to start (bootstrap) the Drupal database.

From my preparations before getting Drush installed, I noticed in the above code that I am missing three distinct lines in my status overview that I do see referenced when doing some research:

     Database                :  Connected
     Drupal bootstrap        :  Successful
     Drupal user             :  Anonymous

This is the reason why I started this post with mentioning that I believe there is something wrong with the database connection. However, I do not understand this, as my Drupal site functions fine, which means that the settings in my "settings.php" must be okay.

One might think that these pointers should give ample leads to find a solution. I have gone through the chapter on Drush in "The Definitive Guide to Drupal 7" by Greg Anderson, and I can assure you that I have spend countless hours in the past weeks on getting Drush to work properly on my system by searching the internet high and low on anything I could find on Drush. And yes there are plenty of tutorials to find, plenty of posts from people that have issues that look like mine (but not exactly), but still I have not been able to get it to work, or I am just not seeing it.

What came up a lot is the advice to change the 'host' setting in my "settings.php" from "localhost" to "127.0.0.1.", which I did (as you can see from the status overview above). There were some references to specify the 'port' setting to "3306", which I also tested, but without success.

Now, I can not exclude the fact that perhaps my lack of knowledge and/or experience is a reason that I might be overseeing an obvious reason for my issue. I am fairly new at building sites (with Drupal), and in the past 6 months going through a pretty steep Drupal learning curve. I have read a couple of books on Drupal and started building a site without doing any coding. I came across Drush a couple of times, installed it a few months back, but could not get it to work, so left it as it was. Now I need to start theming my site and wanted to start using the Omega 3 subtheme that I created months back (but not yet really worked with). Now with the new Omega 4 theme out, it makes sense to skip Omega 3 and start with Omega 4. But in order to create a subtheme I need Drush to work, as there is no good documentation explaining the manual process (although I have asked for it). So as you can see, I am in need to get Drush working, which needs to happen anyway, as everything I read about it tells me that I really should start using it. So I could use the help of anybody "listening".

What I should mention also is the the fact that I guess it does not help that I am not an expert on linux, apache, php and working with the command line. From many of the internet posts that I have read I must conclude that I am missing a lot of background knowledge. But I am not giving up yet, and I am willing to learn. The appeal of what Drupal can do is big and most of the time I am enjoying the ride....

7
  • 1
    You're running Drupal on a NAS device as like a shared folder? Odd, but OK. Where is your MySQL instance running? Under windows? or something else. Since it's not reachable is MySQL turned on? Is your firewall (if any) denying access to port 3306?
    – tenken
    Sep 2, 2013 at 21:12
  • 1
    @tenken makes a good point. If your Drupal installation is on a shared device, is MySQL also installed on the same device? As in, if it's not, it probably has a different IP address relative to your computer. Just to be sure, is your Drupal site actually up and running? Sep 3, 2013 at 0:56
  • The Synology NAS runs its own Apache web server and is fully capable of hosting a (small) website (without too much traffic). This means that it runs with a functioning MySQL database.
    – Ben
    Sep 3, 2013 at 19:38
  • @tenken: I had not thought about the firewall as I am working within my LAN, but I just shut it down and the issue is still there.
    – Ben
    Sep 3, 2013 at 19:47
  • 1
    Is Drush installed on your local Windows machine, or on the NAS device? You realize Drush runs on a system meaning Drush considers 127.0.0.1 to be localhost (where your typing CLI commands). But you say MySQL lives on the NAS and powers your smaller site.
    – tenken
    Sep 3, 2013 at 22:45

2 Answers 2

1

From your comment:

One thing I did not try yet is to use an alias containing connection parameters
But that should not be necessary, as Drush should be able to read my settings.php file that contains that information already

Actually, it makes sense that Drush can't connect with the settings.php file in your case. Let's try to explain that.

You mentioned that settings.php contains 127.0.0.1 or localhost as the hostname of the MySQL server. This is a special address that means myself for every computer or device, including the NAS.

When the Drupal website runs on the NAS with its own webserver and connects to 127.0.0.1, it connects to the MySQL server on the NAS.

On the other hand, when Drush runs on your PC and tries to connect to 127.0.0.1, it designates the PC, so that connection fails with the mentioned error because MySQL is installed on the NAS, not the PC.

What makes your setup special is that you're installing Drush on a different machine (the PC) than the webserver (the NAS). Hence the suggestion to refer to Drupal as a remote installation from the point of view of the PC.

There's possibly an easier way, however, provided MySQL was configured to listen to the interface of the local network. If the NAS was at address, say 192.168.x.y, on the local network, both the NAS itself and the PC could refer to this address via settings.php, and then it would work identically from the web server and from Drush.

1
  • Your reply makes more than perfect sense and I do believe that the answer to my issue lies in your explanation. I quickly tried the approach of using my LAN IP address of the NAS, but that did not work for Drush either, while I lost the connection between Drupal and the database. So next thing I will try is the alias with 'remote' connection parameters. It will take a couple of days before I can test, but will respond with the outcome of my tests.
    – Ben
    Sep 8, 2013 at 19:47
0

Your database connection is dying/crippling because of low computing resources on your NAS, I would suggest using anyone of the following free cloud solution for dev work :

  1. https://www.openshift.com/videos/openshift-express-getting-started-with-drupal
  2. http://www.turnkeylinux.org/drupal7 (Use free tier from Amazon with one-click launch).
  3. https://www.acquia.com/products-services/dev-desktop For Local devlopment on Windows

Both of the above come pre-installed with a complete drupal development env. including Drush.

5
  • Thanks for your input, but my Synology NAS is a DS412+, which should have no problem whatsoever running a (small) web site. So I have difficulties to believe that Drush is putting so much strain on the system that it can not handle it anymore.
    – Ben
    Sep 3, 2013 at 19:51
  • OK, I would still suggest you try a pre-configured Windows drupal dev solution like Acquia Dev Desktop (it's requires no registration and works without any need to go with acquia). Sep 4, 2013 at 2:47
  • Thanks for the suggestion. Will have a look at Acquia Dev Desktop, but still hope that I can get Drush working on my current NAS.
    – Ben
    Sep 4, 2013 at 19:59
  • This seems more like a db-server issue not drush. Edit- Read your last comment if mysql is working for another site try re-installing Drush and use drush alias file. Sep 5, 2013 at 1:45
  • 1
    I agree that it seems to be a database issue. But my Drupal site works fine with the database that I created for it. Question is really why Drush is not connecting to that database. One thing I did not try yet is to use an alias containing connection parameters. But that should not be necessary, as Drush should be able to read my settings.php file that contains that information already.
    – Ben
    Sep 5, 2013 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.