PacktPublishing / Django-4-by-example

Django 4 by example (4th Edition) published by Packt
https://djangobyexample.com/
MIT License
818 stars 461 forks source link

Chapter 17, CRITICAL Listen failure: Couldn't listen on any:b'/code/educa/daphne.sock': Cannot acquire lock. #54

Open jmpmcmanus opened 1 year ago

jmpmcmanus commented 1 year ago

In chapter 17 I'm getting the following error related to daphne:

CRITICAL Listen failure: Couldn't listen on any:b'/code/educa/daphne.sock': Cannot acquire lock.

I tried stoping the docker-compose deleting the daphne.sock and restarting docker-compose and get the same error. A daphne.sock.lock file is also created, which is actually link to: daphne.sock.lock --> 1. I remove that as well before starting docker-compose again.

Jim

alfonsomiralles commented 1 year ago

I have the same problem

mojoelogic commented 10 months ago

I'm trying to finish this book before new years(so today) and I'm stuck on the same problem.

@jmpmcmanus and @alfonsomiralles did either of you get it sorted?

zenx commented 8 months ago

There seems to be an issue with Daphne related to UNIX sockets. You can run Daphne via host/port instead of UNIX socket:

docker-compose.yml

daphne:
  command: ["../wait-for-it.sh", "db:5432", "--",
            "daphne", "-b", "0.0.0.0", "-p", "9001",
            "educa.asgi:application"]
# ...

Nginx config:

upstream daphne {
    server daphne:9001;
}
AlexNeo68 commented 8 months ago

There seems to be an issue with Daphne related to UNIX sockets. You can run Daphne via host/port instead of UNIX socket:

docker-compose.yml

daphne:
  command: ["../wait-for-it.sh", "db:5432", "--",
            "daphne", "-b", "0.0.0.0", "-p", "9001",
            "educa.asgi:application"]
# ...

Nginx config:

upstream daphne {
    server daphne:9001;
}

It is working! Thanks a lot!