1

Using drush 11 and Drupal 9 to test a local site on my Mac (using MAMP), I'm having difficulty getting site aliases to work. I used Drush Launcher to make my drush executable globally. I also created <DRUPAL_ROOT>/drush/sites/self.site.yml containing:

local:
  host: www.en9-local.pglatz.com
  user: pglatz
  root: /Users/pglatz/dev/electronovelty/en9-www/web
  uri: https://en9-local.pglatz.com

If I cd to my project root and type drush wd-show I see the status command correctly. But if I try using my alias with it, i.e. drush @local wd-show I get this error:

ssh: connect to host www.en9-local.pglatz.com port 22: Connection refused

In SiteProcess.php line 214:
                                                                                                                                                                            
  The command "ssh -t -o PasswordAuthentication=no pglatz@www.en9-local.pglatz.com 'drush wd-show --uri=https://www.en9-local.pglatz.com --root=/Users/pglatz/dev/electron  
  ovelty/en9-www/web'" failed.                                                                                                                                              
                                                                                                                                                                            
  Exit Code: 255(Unknown error)                                                                                                                                             
                                                                                                                                                                            
  Working directory:                                                                                                                                                        

This is a local host, so why is it using ssh? My goal is to have both 'local' and 'prod' aliases so can can run Drush on my production server.

2
  • 2
    Aliases are for remotes. You don't need to create one for your local site. It's there already: @self. You just use drush wd-show or drush @self wd-show. Syncing a database down from Dev to Local then after having setup the dev: alias properly would be drush sql-sync @dev @self -y for example.
    – leymannx
    Apr 11 at 7:34
  • 1
    Aliases can also be created for local sites @leymannx (drush.org/latest/site-aliases). Might not be necessary for OP's specific problem as you said, of course
    – Clive
    Apr 11 at 8:29

1 Answer 1

1

If you look at the Site aliases docs you'll see this:

host: The fully-qualified domain name of the remote system hosting the Drupal instance. The host option must be omitted for local sites, as this option controls various operations, such as whether or not rsync parameters are for local or remote machines, and so on.

Emphasis mine. You can also remove user as it's only relevant to SSH connections.

Make sure you also read the section titled "Advanced usage", as it contains more information about using local site aliases specfically.

Also bear in mind Leymannx's comment, though - if this is a single site you're managing from that same site's docroot, just use the built in @self, no need to create a new alias.

1
  • Thanks to all for the clear explanations. I do maintain multiple sites and liked to use aliases for them when I was working with Drupal 7.
    – pglatz
    Apr 11 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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