Capistrano 3: Connection refused - connect(2)

707 views
Skip to first unread message

R

unread,
Jun 2, 2014, 12:21:38 PM6/2/14
to capis...@googlegroups.com

Hello guys,

I am trying to set up Capistrano 3 for my Rails 4 application, the setup is following:

deploy.rb

---

SSHKit.config.command_map[:rake] = "bundle exec rake"
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'myapp'
set :scm, :git set
set :repo_url, 'g...@bitbucket.org:username/repo.git'
set :stages, ["staging", "production"]
set :default_stage, "staging"
set :format, :pretty set
set :pty, true
set :keep_releases, 5
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
# execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, :restart after
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end

and in deploy/staging.rb:

role :app, %w{deployer@IP_ADDRESS}
role :web, %w{deployer@IP_ADDRESS}
role :db, %w{deployer@IP_ADDRESS} server "IP_ADDRESS", user: 'deployer', roles: %w{app web db}
set :deploy_to, "/home/deployer/apps/myapp-staging" set :ssh_options, {
forward_agent: false,
auth_methods: %w(password),
password: 'my_password',
user: 'deployer',
}

When I run

cap staging deploy 

I get:
INFO [f15d031b] Running /usr/bin/env mkdir -p /tmp/myapp/ on IP_ADDRESS DEBUG
DEBUG [f15d031b] Command: /usr/bin/env mkdir -p /tmp/myapp/
cap aborted!
Errno::ECONNREFUSED: Connection refused - connect(2) 

Why Capistrano can't deploy the app on the staging server?

Thank you in advance for every help. 

Lee Hambley

unread,
Jun 2, 2014, 1:46:45 PM6/2/14
to capistrano
Your staging server is unreachable.

--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/2fbc6b53-7114-4ef8-8239-07dd779a2cf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

R

unread,
Jun 2, 2014, 2:45:30 PM6/2/14
to capis...@googlegroups.com
But I can log in with the credentials through SSH, does it mean, that I miss something in the deploy.rb/staging.rb file?

Lee Hambley

unread,
Jun 2, 2014, 2:54:38 PM6/2/14
to capistrano
​I'd guess so, but you took too much out of the logs for us to help.​

R

unread,
Jun 2, 2014, 3:01:15 PM6/2/14
to capis...@googlegroups.com
I am attaching the whole log:

** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke deploy (first_time)
** Execute deploy
** Invoke deploy:starting (first_time)
** Execute deploy:starting
** Invoke deploy:check (first_time)
** Execute deploy:check
** Invoke git:check (first_time)
** Invoke git:wrapper (first_time)
** Execute git:wrapper
INFO [59f586b5] Running /usr/bin/env mkdir -p /tmp/project_name/ on IP_ADDRESS
DEBUG [59f586b5] Command: /usr/bin/env mkdir -p /tmp/project_name/

cap aborted!
Errno::ECONNREFUSED: Connection refused - connect(2)
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:70:in `initialize'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:70:in `open'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:70:in `block in initialize'
/Users/radek/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
/Users/radek/.rvm/rubies/ruby-1.9.3-p385/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:67:in `initialize'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/net-ssh-2.8.0/lib/net/ssh.rb:200:in `new'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/net-ssh-2.8.0/lib/net/ssh.rb:200:in `start'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/sshkit-1.4.0/lib/sshkit/backends/connection_pool.rb:24:in `create_or_reuse_connection'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:173:in `ssh'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:126:in `block in _execute'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:66:in `execute'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/capistrano-3.1.0/lib/capistrano/tasks/git.rake:17:in `block (3 levels) in <top (required)>'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/sshkit-1.4.0/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/radek/.rvm/gems/ruby-1.9.3-p385/gems/sshkit-1.4.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => git:check => git:wrapper
The deploy has failed with an error: #<Errno::ECONNREFUSED: Connection refused - connect(2)>
** Invoke deploy:failed (first_time)
** Execute deploy:failed

Thanks

and in deploy/staging.rb:

<code style="font-size:13.63636302947998px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono&#39
...

Lee Hambley

unread,
Jun 2, 2014, 3:11:54 PM6/2/14
to capistrano
the address you have specified for your staging server is unreachable.

--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.

R

unread,
Jun 2, 2014, 3:23:09 PM6/2/14
to capis...@googlegroups.com
Ok, so I killed one afternoon because of not specifying the port number.
Thanks for pointing me out.
...
Reply all
Reply to author
Forward
0 new messages