Puma, Nginx and rails5 not working

I’ve followed this guide step by step, and I’ve this error

“1256#0: *12 connect() to unix:///home/me/app/shared/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream”

If I create the puma.sock file, and I give, as a test, 777 permission, I have this error: " [error] 1256#0: *14 connect() to unix:///home/me/app/shared/tmp/sockets/puma.sock failed (111: Connection refused) while connecting to upstream"

If I follow this other tutorial,, the file uploaded to shared/puma.rb contains wrong values, the path of the socket is pointing to /var/www instead to /home/me

this is my puma config file:

# Change to match your CPU core count
workers 1

# Min and Max threads per worker
#threads 1, 6

app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"

# Default to production
rails_env = "production"
environment rails_env

# Set up socket location
bind "unix://#{shared_dir}/sockets/puma.sock"

# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true

# Set master PID and state locations
pidfile "#{shared_dir}/pids/"
state_path "#{shared_dir}/pids/puma.state"

on_worker_boot do
  ActiveRecord::Base.establish_connection if defined?(ActiveRecord)

This is my deploy file:

# config valid only for current version of Capistrano
lock '3.8.1'

set :application, 'app'
set :repo_url, ''

set :pty,             true
set :use_sudo,        false
set :stage,           :production
set :deploy_via,      :remote_cache
set :ssh_options,     { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/ }

set :repo_url, 'ssh://me@'
set :deploy_to, "/home/me/app"

set :rbenv_ruby, '2.4.1'

# Default value for :format is :pretty
set :format, :pretty

set :bundle_without, %w{development test}.join(' ')
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')

set :keep_releases, 5

namespace :puma do
  desc 'Create Directories for Puma Pids and Socket'
  task :make_dirs do
    on roles(:app) do
      execute "mkdir #{shared_path}/tmp/sockets -p"
      execute "mkdir #{shared_path}/tmp/pids -p"

  before :start, :make_dirs

namespace :deploy do
  after :finishing, 'deploy:cleanup'
  after 'deploy:publishing', 'deploy:restart'
  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, 'tmp:clear'

  desc "Make sure local git is in sync with remote."
  task :check_revision do
    on roles(:app) do
      unless `git rev-parse HEAD` == `git rev-parse origin/master`
        puts "WARNING: HEAD is not the same as origin/master"
        puts "Run `git push` to sync changes."

  desc 'Initial Deploy'
  task :initial do
    on roles(:app) do
      before 'deploy:restart', 'puma:start'
      invoke 'deploy'

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      invoke 'puma:restart'

  before :starting,     :check_revision
  after  :finishing,    :compile_assets
  after  :finishing,    :cleanup
  after  :finishing,    :restart


This is my site-available/

upstream myapp {
    server unix:///home/me/app/shared/tmp/sockets/puma.sock fail_timeout=0;

server {
    listen       80;
    root /home/ma/app/current/public;

    try_files $uri/index.html $uri @puma;
    location @puma {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_pass http://myapp;

    error_page 500 502 503 504 /500.html;
    location = /500.html {
        root /home/me/app/current/public;

I’ve already read these:

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Yes, Puma was not running, the problem was in my deploy file. since capistrano-3, the restart is automatic, this part:

  after  :finishing,    :restart

Needed to be removed, otherwise i have a warning AND puma was not started

Does anyone know how to point the upstream server to an APP server ip?

I have two server, App and Web, Web handles the NGINX and app is where the source code is stored and puma is running.

How can I point the web instance server to app instance server

upstream myapp {
    server unix:///home/me/app/shared/tmp/sockets/puma.sock fail_timeout=0;

puma.sock is a unix socket file that puma is supposed to listen on—puma should create it once it’s started. It sounds like puma is not running. Try running cap production puma:start and cap production puma:status (to check if the start command was successful).