views:

252

answers:

3

I'm getting a port error when I try to deploy my app via:

cap deploy:cold

The error:

ssh: connect to host domain.com port 22: Connection refused

My deploy.rb (replaced sensitive info where appropriate):

set :user, 'user'
set :domain, 'domain.com'
set :application, "App Name"

# file paths
set :repository,  "[email protected]:git/appname.git"
set :port, 9728
set :deploy_to, "/home/ruby/public_html/appname"

# distribute your applications across servers (the instructions below put them)
# all on the same server, definied above as 'domain', adjust as necessary
role :web, domain
role :app, domain
role :db,  domain, :primary => true

# you might need to set this if you aren't seeing password prompts 
# default_run_options[:pty] = true

# As Capistrano executes in a non-interactive mode and therefore doesn't cause 
# any of your shell profile scripts to be run, the following might be needed 
# if (for example) you have locally installed gems or applications. Note: 
# this needs to contain the full values for the variables set, not simply
# the deltas. 

# miscellaneous options
set :deploy_via, :remote_cache
set :scm, :git
set :branch, 'master'
set :scm_verbose, true
set :use_sudo, false

# task which causes Passenger to initiate a restart

namespace :deploy do
  task :restart do
    run "touch #{current_path}/tmp/restart.txt"
  end
end

# optional task to reconfigure databases
after "deploy:update_code", :configure_database
desc "copy database.yml into the current release path"
task :configure_database, :roles => :app do
  do_config = "#{deploy_to}/config/database.yml"
  run "cp #{db_config} #{release_path}/config/database.yml"
end

I understand the error, but can't see where to make the change. I figured :set port, would handle it.

A: 

Sorry to state the obvious, but:

  • Is the port actually open on the server?
  • Have you changed it to something else?
  • Is it accessible from the outside?
  • Is your firewall blocking it?
Josh
No worries - I appreciate your help. Yes, port was open - I wanted it to be away from the default 22 per host recommendations. It's accessible from regular SHH root and sudo user logins.
Steve
A: 

Have you tried putting the port in your repository path ? Something like ssh://[email protected]:9728/git/appname.git

I think Capistrano only uses the port you specify in set :port to log in your remote servers.

agregoire
Changed to:set :repository, "ssh://[email protected]:9728/~/git/appname.git"But now I have more errors! Hehe. I'll work on it, and if I get stuck I'll post another question later. Thanks for your help agregoire!
Steve
A: 

Here's what works: you must have

set :port, port#
set :repository, "ssh://#{user}@IPAddress:#{port}/~/path/to/git

Or also try: Here's a possible fix. add ssh_options[:port] = port# May work

ScotterC