puma.sock failed (111: Connection refused) while connecting to upstream(mina,puma,nginx,rails)

July 1, 2016 19k views
Ruby on Rails Nginx Ubuntu Ruby

this my error puma.sock failed (111: Connection refused) while connecting to upstream


#!/usr/bin/env puma

environment ENV['RAILS_ENV'] || 'production'

daemonize true

pidfile "/home/alif/www/ozinteractive/shared/tmp/pids/puma.pid"
stdout_redirect "/home/alif/www/ozinteractive/shared/tmp/log/stdout", "/home/alif/www/ozinteractive/shared/tmp/log/stderr"

threads 0, 16

bind "unix:///home/alif/www/ozinteractive/shared/tmp/sockets/puma.sock"


#! /bin/sh


# check if puma process is running
puma_is_running() {
  if [ -S $PUMA_SOCKET ] ; then
    if [ -e $PUMA_PID_FILE ] ; then
      if cat $PUMA_PID_FILE | xargs ps -p -P > /dev/null ; then
        return 0
        echo "No puma process found"
      echo "No puma pid file found"
    echo "No puma socket found"

  return 1

case "$1" in
    echo "Starting puma..."
      rm -f $PUMA_SOCKET
      if [ -e $PUMA_CONFIG_FILE ] ; then
        bundle exec puma -C $PUMA_CONFIG_FILE
        bundle exec puma

    echo "done"

    echo "Stopping puma..."
      kill -s TERM `cat $PUMA_PID_FILE`
      rm -f $PUMA_PID_FILE
      rm -f $PUMA_SOCKET

    echo "done"

    if puma_is_running ; then
      echo "Hot-restarting puma..."
      kill -s USR2 `cat $PUMA_PID_FILE`

      echo "Doublechecking the process restart..."
      sleep 5
      if puma_is_running ; then
        echo "done"
        exit 0
        echo "Puma restart failed :/"

    echo "Trying cold reboot"
    bin/puma.sh start

    echo "Usage: bin/puma.sh {start|stop|restart}" >&2

9 Answers

While this is not an issue I have personally dealt with before, here are the steps I would take to start troubleshooting:

1.) Make sure puma is running and that the socket exists in your filesystem as it should.
2.) Check that your upstream nginx server is pointed to the correct socket file and there is not more information on the issue in it’s logs.

I would also recommend reviewing our guide for this configuration and going back through the steps to ensure you did not miss anything.

by Mitchell Anicas
When you are ready to deploy your Ruby on Rails application, there are many valid setups to consider. This tutorial will help you deploy the production environment of your Ruby on Rails application, with PostgreSQL as the database, using Puma and Nginx on Ubuntu 14.04. Puma...

Having this same issue. Was there a solution found?

I’m having this same issue as well. Anyone have any clues on how to fix? It happened right after I deployed via mina.

Is there any solution

Is there any news regarding this issue?

right the solution is most likely non exsisting folders:

first check if you have created your socket, logs and pids folders that you have defined in your puma.rb and also with the correct rights

if the problem still persists after that, go to your puma log folder and check the error message in the log file which prevents the puma server from booting usually a ruby code error at this point

  • I was struggling with a similar problem and your comment help me to figure it out that i must create the 3 folders (socket, logs and pids).


in my particular case, the problem was an error in my code.
check the puma.error.log file

Hope this is helpful!!!

Hi! In my case it was missing folders indeed. I was missing the folders that were supposed to hold the socket.

Have another answer? Share your knowledge.

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