-1

I followed the guide on deploying to aws ec2 https://www.sitepoint.com/deploy-your-rails-app-to-aws/.

I am using ubuntu 16 server.

Everything has installed perfectly on the server but when i run cap production deploy --trace this is the output.

** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rvm:hook (first_time)
** Execute rvm:hook
** Invoke rvm:check (first_time)
** Execute rvm:check
cap aborted!
Net::SSH::ConnectionTimeout: Net::SSH::ConnectionTimeout
/var/lib/gems/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:90:in `rescue in initialize'
/var/lib/gems/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:57:in `initialize'
/var/lib/gems/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh.rb:232:in `new'
/var/lib/gems/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh.rb:232:in `start'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/connection_pool.rb:59:in `call'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/connection_pool.rb:59:in `with'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/netssh.rb:155:in `with_ssh'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/netssh.rb:108:in `execute_command'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:141:in `tap'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:60:in `capture'
/var/lib/gems/2.1.0/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:9:in `block (3 levels) in <top (required)>'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:29:in `run'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Errno::ETIMEDOUT: Connection timed out - connect(2) for 172.31.11.127:22
/usr/lib/ruby/2.1.0/socket.rb:65:in `connect'
/usr/lib/ruby/2.1.0/socket.rb:65:in `connect_internal'
/usr/lib/ruby/2.1.0/socket.rb:140:in `connect'
/usr/lib/ruby/2.1.0/socket.rb:338:in `block in tcp'
/usr/lib/ruby/2.1.0/socket.rb:232:in `each'
/usr/lib/ruby/2.1.0/socket.rb:232:in `foreach'
/usr/lib/ruby/2.1.0/socket.rb:328:in `tcp'
/var/lib/gems/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:70:in `initialize'
/var/lib/gems/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh.rb:232:in `new'
/var/lib/gems/2.1.0/gems/net-ssh-3.2.0/lib/net/ssh.rb:232:in `start'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/connection_pool.rb:59:in `call'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/connection_pool.rb:59:in `with'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/netssh.rb:155:in `with_ssh'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/netssh.rb:108:in `execute_command'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:141:in `tap'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:60:in `capture'
/var/lib/gems/2.1.0/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:9:in `block (3 levels) in <top (required)>'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/backends/abstract.rb:29:in `run'
/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rvm:check

My Capistrano production.rb file:

server '172.31.11.127', user: 'deploy', roles: %w{web app db}

My Capistrano deploy.rb file:

set :branch, :master   
set :deploy_to, '/home/deploy/rd'
set :pty, true

set :linked_files, %w{config/database.yml config/application.yml}

set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}


set :keep_releases, 5  
set :rvm_type, :user
set :rvm_ruby_version, 'ruby 2.1.5'

set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"    #accept array for multi-bind
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 8]
set :puma_workers, 0
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :puma_preload_app, false
CDub
  • 13,146
  • 4
  • 51
  • 68
Vic Turuthi
  • 5
  • 1
  • 4
  • try to check on the command line ssh ubuntu@52.2.139.74 and when you add your public key in server authorized_keys file, needs to restart ssh service – Pratap Nov 17 '16 at 12:29
  • i restarted the service and still getting the error. Who or what does the ip 52.2.139.74 belong to? – Vic Turuthi Nov 17 '16 at 12:45
  • sry mistake for ip 52.2.139.74 – Pratap Nov 17 '16 at 12:49
  • I'm guessing you don't have a `deploy` user on your Ubuntu instance... Perhaps try with the `ubuntu` user, as Capistrano is trying to SSH to your instance as `deploy@`. – CDub Nov 18 '16 at 22:27

1 Answers1

0

Connection Timeout means that some firewall rule is blocking your ssh connection on port 22 to the machine it is deploying the code. The message below -

/var/lib/gems/2.1.0/gems/sshkit-1.11.4/lib/sshkit/runners/parallel.rb:12:inblock (2 levels) in execute' Errno::ETIMEDOUT: Connection timed out - connect(2) for 172.31.11.127:22 /usr/lib/ruby/2.1.0/socket.rb:65:in connect'

clearly shows that the connection timeout's after timeout period expires on the client machine. As I see that you are using capistrano inside aws instance , check for your security group of the client machine to which the capistrano machine is trying to connect. Port 22 should be open for atleast the ip/subnet of the capistrano machine.