Pantheon Helpdesk

Welcome, Guest Login

Support Center

Using Drush on Pantheon

Last Updated: Mar 18, 2013 03:36PM PDT

Drush is a command line interface for Drupal that provides a wide set of utilities for administering and maintaining your site. We provide a Drush portal in addition to git access, rsync and sftp, and "On Server Development". This gives you multiple options when it comes to managing your code, additional files, and data.

Pantheon currently supports Drush version 5.1.

To get started log in to your Pantheon dashboard and click on the "Download all Drush aliases" button to get the most current version of your compiled drushrc.php file:

Download your Drush aliases

Setting up the drush aliases file

If you are on linux/MacOS environment you can then put this file into a .drush directory in your home, or you can also put it in the aliases directory of your local Drush installation.

Drush will search for aliases in any of these files using the alias search path. The following locations are examined for alias files:

  1. In any path set in $options['alias-path'] in drushrc.php, or (equivalently) any path passed in via --alias-path=... on the command line.
  2. If 'alias-path' is not set, then in one of the default  locations:
    • a. /etc/drush
    •  b. In the drush installation folder
    •  c. Inside the 'aliases' folder in the drush installation folder
    •  d. $HOME/.drush 
  3. Inside the sites folder of any bootstrapped Drupal site, or any local Drupal site indicated by an alias used as a parameter to a command

Connecting via Drush

With the drush alias file in place, the last step is to check if everything is working. You can try to get a list of all the available aliases for your account by running drush sa:

# drush sa
@pantheon.open-public-demo.dev
@pantheon.open-public-demo.test
@pantheon.open-public-demo.live
@pantheon.drupal-7-sandbox.dev
@pantheon.drupal-7-sandbox.test
@pantheon.drupal-7-sandbox.live

When you have confirmed that your Drush aliases are working you can try and run the Drush commands of your choice:

# drush @pantheon.drupal-7-sandbox.dev status
Drupal version : 7.10 Site URI : dev.drupal-7-sandbox.gotpantheon.com
Database driver : mysql Database hostname : 50.57.231.252
Database username : pantheon Database name : pantheon
Database : Connected
Drupal bootstrap : Successful
Drupal user : Anonymous
Default theme : waves
Administration theme : seven
PHP configuration : /srv/bindings/12bda2a361064ce680fb4218871a33e5/php.ini
Drush version : 5.1
Drush configuration : /srv/bindings/12bda2a361064ce680fb4218871a33e5/drushrc.php
Drush alias files : Drupal root : . Site path : sites/default
File directory path : sites/default/files Private file : sites/default/files/private directory path

Troubleshooting

Can not connect using site aliases

If you are having issues connecting to your Pantheon site using Drush. Please make sure that you have correctly setup your Drush alias file. The correct alias for your site would probably be pantheon.drupal-7-sandbox.dev. Use the drush sa command to get a list of available aliases.

Debugging failed Drush commands

When you do not have a settings.php within your _sites/default/_ directory drush may fail to execute certain commands. Some of the symptoms are the missing system information from the status command such as: Database name, Database hostname, Database driver.

To resolve this simply add the settings.php for your version of Drupal to the correct path and you will be able to use drush on your site. In order test this try running drush status and see if you get the following output:

drush @pantheon.example.dev status
 Drupal version        :  7.12                                                  
 Default theme         :  garland                                               
 Administration theme  :  garland                                                                                                                          
 PHP configuration     :  /srv/bindings/d51d98318ec1ada7cad0c132409de6b50/php.ini                                          
 Drush version         :  5.1                                                   
 Drush configuration   :  /srv/bindings/d51d98318ec1ada7cad0c132409de6b50/drushrc.php                                                 
 Drupal root           :  .   

Drush commands with known issues

The following Drush commands are known to not work on Pantheon:

sql-sync
sql-sqlc
php-eval

As an alternative to sql-dump you can use the mysqldump command:

mysqldump -u USERNAME -p DATABASENAME > /path/to/backup_dir/database-backup.sql

Stay tuned for updates as we work on more complete support. Please report issues with other commands to the helpdesk.

Drush commands that alter the filesystem

If you are going to use commands that alter the files on your Pantheon server's filesystem it is important to enable "On server development" from your Pantheon administration dashboard.

This is because making changes to the files on the server can create conflicts with your git repository, which can cause problems when you are trying to push or pull your code. Examples of commands that require you to enable "On server development" are dl or pm-update.

Drush aliases not working

Could not find a Drupal settings.php file at [error] 
./sites/default/settings.php

Pantheon does not need the settings.php for your site to work, however to use certain remote Drush commands you need a settings.php file. There is some more information about that here: http://drupal.stackexchange.com/a/22809

You can add your own simple settings.php file in sites/default as a stub and that should resolve that issue for you. From there you should be able to use the commands such as pm-update on your Pantheon site

Resolving DNS Issues

Some ISP's have issues resolving a drush.in hostname; if you're having trouble connecting to a drush.in hostname, you can use the "dig" command to investigate further.

ricky@Leadbelly:~$ dig appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in
;; Truncated, retrying in TCP mode.

; <<>> DiG 9.8.1-P1 <<>> appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 38905
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. IN A

;; Query time: 11 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Thu Aug 30 12:28:25 2012
;; MSG SIZE  rcvd: 78

As you can see in the output above, the status: REFUSED suggests improper resolution. The next step is to try running "dig" with a specified DNS server. We recommend using Google's DNS (8.8.8.8):

ricky@Leadbelly:~$ dig @8.8.8.8 appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in
;; Truncated, retrying in TCP mode.

; <<>> DiG 9.8.1-P1 <<>> @8.8.8.8 appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 36494
;; flags: qr rd ra; QUERY: 1, ANSWER: 34, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. IN A

;; ANSWER SECTION:
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 67.207.144.213
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.166.96.43
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.166.96.153
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 208.78.100.22
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.57.135.63
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 67.207.148.45
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.57.135.237
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 67.207.144.162
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 184.106.80.231
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.171.162.76
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.166.110.21
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 208.78.97.145
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.56.95.251
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.56.95.251
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.57.164.228
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.166.112.58
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 208.78.100.201
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.171.175.71
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.171.172.17
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.57.187.158
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 209.20.65.198
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.57.50.79
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.56.95.251
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.57.135.37
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.171.162.76
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.171.173.71
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.166.58.222
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 184.106.116.77
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.166.96.153
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.57.135.15
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 50.57.226.212
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 108.171.172.17
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 209.20.91.157
appserver.live.38f2bd91-0000-46cb-9278-0000000000000.drush.in. 599 IN A 67.207.143.122

;; Query time: 52 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Aug 30 13:02:00 2012
;; MSG SIZE  rcvd: 622

Detecting the Issue

As you can see in the output above, Google's DNS is able to properly resolve the drush.in hostname.

You can adjust your local settings to use Google's DNS (8.8.8.8) instead of the default provided by your ISP to properly resolve the hostnames.

Contact Us

helpdesk@getpantheon.com
http://assets2.desk.com/r1046ffeaa2233e531563a32d7edef6677d8a78b5/javascripts/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/portal/articles/autocomplete