Error setting up SSL - CRITICAL Listen failure: Couldn't listen on any:8000: [Errno 98] Address already in use.
KensingtonOscupant opened this issue · comments
I am trying to set up SSL with Daphne using the Nginx/Supervisor setup from the Channels docs on an AWS EC2 Ubuntu 22.04 instance, but I keep getting the following error in my logs:
2022-10-18 10:14:36,609 INFO Starting server at fd:fileno=0, ssl:8000:privateKey=/etc/letsencrypt/live/example.com/privkey.pem:certKey=/etc/letsencrypt/live/example.com/fullchain.pem, unix:/run/daphne/daphne0.sock
2022-10-18 10:14:36,610 INFO HTTP/2 support enabled
2022-10-18 10:14:36,610 INFO Configuring endpoint fd:fileno=0
2022-10-18 10:14:36,623 INFO Listening on TCP address [the EC2 IP]:8000
2022-10-18 10:14:36,623 INFO Configuring endpoint ssl:8000:privateKey=/etc/letsencrypt/live/example.com/privkey.pem:certKey=/etc/letsencrypt/live/example.com/fullchain.pem
2022-10-18 10:14:36,628 CRITICAL Listen failure: Couldn't listen on any:8000: [Errno 98] Address already in use.
2022-10-18 10:14:36,629 INFO Configuring endpoint unix:/run/daphne/daphne0.sock
However, lsof -i TCP:8000 | grep LISTEN
does not return anything.
The daphne instructions I have in my supervisor command are
daphne -e ssl:8000:privateKey=/etc/letsencrypt/live/example.com/privkey.pem:certKey=/etc/letsencrypt/live/example.com/fullchain.pem -u /run/daphne/daphne%(process_num)d.sock --endpoint fd:fileno=0 --access-log - --proxy-headers stream.asgi:application
A similar seems to appear here. The SSL certificate I used here is also used by Nginx for port 443.
Changing the port in ssl:
to one other than (in my case) 8000 solved it.