Score:1

Drush site aliases not working as expected

in flag

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 [email protected] '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.

leymannx avatar
ne flag
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.
cn flag
Aliases can also be created for local sites @leymannx (https://www.drush.org/latest/site-aliases/). Might not be necessary for OP's specific problem as you said, of course
Score:1
cn flag

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.

pglatz avatar
in flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.