Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

933
Views
unix:///var/run/supervisor.sock refused connection during restarting supervisor

When I created a new .conf file inside /etc/supervisor/conf.d/ and tried to start this program it was showing some errors (fatal error) and restarting frequently by itself. Then I ran the command sudo service supervisor restart but now the supervisor also stopped and couldn't be restarted it. During solving my error the nginx server also got stuck also.

After spending a vast time I recovered it Alhamdulillah and writing the solution in the answer section.

Don't trust the solution entirely for your problem. Your problem may belong to another issues as well.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Sometime Supervisor can show the below horrible error when you restart the service (by the command sudo service supervisor restart):

unix:///var/run/supervisor.sock refused connection

Try to diagnosis the problem with the command supervisord. You can also run journalctl -xe.

Problems and Solutions:

  1. When you write a new .conf file to inside the /etc/supervisor/conf.d directory which contains some statements that are generating error. Like, you write some statements that will run a script. That script contains some statements that runsGunicorn to deploy a python web apps. In the script you wrote a statement to bind an unix socket. But the mentioned directory where the unix socket will be created doesn't give permission to create the .sock file there. This can lead the permission error.

    The demo gunicorn command is below:

SOCKFILE = /home/shamim/python_project/another_directroy/gunicorn.sock
gunicorn ${DJANGO_WSGI_MODULE}:application \
 --name $NAME \
 --bind=unix:$SOCKFILE

If the another_directory doesn't give the permission to create a .sock file inside it then an error can be occurred. So give it enough permission to create something here from outside. Or, Bind IP and port instead unix socket (like 127.0.0.1:ANY_PORT). Be sure first the port is not used by another application.

  1. Sometimes the error can be occurred if any directory path is used inside .conf file but actually that directory doesn't exist at all.

  2. Now run the command supervisord. If the error persists after fixing the above issues and now shows a error like - another program is already listening on a port that one of our HTTP servers is configured to use

    then run the below command to fix this issue:

    sudo unlink /var/run/supervisor.sock

    If the command above does not work you should check run unlink the file at /tmp/supervisor.sock

Keep in mind that the nginx server can also show some errors and fail to restart (or start) if any .conf file contains some statement where a socket is used but actually the socket file doesn't exist or doesn't have enough permission to be executed.

Example: If you write the below code in any nginx file config:

upstream surveyapp_payment_stripe {
    server unix:/home/shamim/python_project/another_directroy/gunicorn.sock fail_timeout=0 weight=5 max_fails=3;
}

If the above socket doesn't exist or not have enough permission then some error may be occurred.

Nginx can also show error if any directory path is used here but not exists at all. To run nginx at this time quickly just delete the .conf file or edit it's extension (make another another extension type other than .conf).

Hopefully this explanation will help someone in future.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!