Failed to start daphne.service - Daphne ASGI Server for Your Django Project

76 Views Asked by At

The whole error:

(venv) gamedeveloper@animechatapp:~$ sudo systemctl status daphne
× daphne.service - Daphne ASGI Server for Your Django Project
     Loaded: loaded (/etc/systemd/system/daphne.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Fri 2023-10-13 10:06:26 UTC; 32s ago
   Duration: 376ms
    Process: 2111 ExecStart=/home/gamedeveloper/venv/bin/daphne -e ssl:8001:privateKey=/etc/letsencrypt/live/www.aniconnect.org/privkey.pem:certKey=/etc/letsencrypt/live/www.aniconnect.org/fullchain.
   Main PID: 2111 (code=exited, status=1/FAILURE)
        CPU: 370ms

Oct 13 10:06:26 animechatapp systemd[1]: daphne.service: Main process exited, code=exited, status=1/FAILURE
Oct 13 10:06:26 animechatapp systemd[1]: daphne.service: Failed with result 'exit-code'.
Oct 13 10:06:26 animechatapp systemd[1]: daphne.service: Scheduled restart job, restart counter is at 5.
Oct 13 10:06:26 animechatapp systemd[1]: Stopped daphne.service - Daphne ASGI Server for Your Django Project.
Oct 13 10:06:26 animechatapp systemd[1]: daphne.service: Start request repeated too quickly.
Oct 13 10:06:26 animechatapp systemd[1]: daphne.service: Failed with result 'exit-code'.
Oct 13 10:06:26 animechatapp systemd[1]: Failed to start daphne.service - Daphne ASGI Server for Your Django Project.

The daphne.service file:

[Unit]
Description=Daphne ASGI Server for Your Django Project
After=network.target

[Service]
User=gamedeveloper
Group=gamedeveloper
WorkingDirectory=/home/gamedeveloper/anime_chat/anime_chat_app
ExecStart=/home/gamedeveloper/venv/bin/daphne -e ssl:8001:privateKey=/etc/letsencrypt/live/www.aniconnect.org/privkey.pem:certKey=/etc/letsencrypt/live/www.aniconnect.org/fullchain.pem anime_chat_app.asgi:application
Restart=always

[Install]
WantedBy=multi-user.target

The journal.ctl output:

(venv) gamedeveloper@animechatapp:~$ sudo journalctl -u daphne
Sep 30 11:34:50 animechatapp systemd[1]: Started daphne.service - Daphne ASGI Server for Your Django Project.
Sep 30 11:34:50 animechatapp daphne[509840]: 2023-09-30 11:34:50,793 INFO     Starting server at tcp:port=8001:interface=194.195.119.237, unix:/tmp/daphne.sock
Sep 30 11:34:50 animechatapp daphne[509840]: 2023-09-30 11:34:50,794 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
Sep 30 11:34:50 animechatapp daphne[509840]: 2023-09-30 11:34:50,794 INFO     Configuring endpoint tcp:port=8001:interface=194.195.119.237
Sep 30 11:34:50 animechatapp daphne[509840]: 2023-09-30 11:34:50,795 INFO     Listening on TCP address 194.195.119.237:8001
Sep 30 11:34:50 animechatapp daphne[509840]: 2023-09-30 11:34:50,795 INFO     Configuring endpoint unix:/tmp/daphne.sock
Sep 30 12:15:51 animechatapp daphne[509840]: Not Found: *
Sep 30 12:15:51 animechatapp daphne[509840]: 2023-09-30 12:15:51,623 WARNING  Not Found: *
Sep 30 12:15:52 animechatapp daphne[509840]: Not Found: /favicon.ico
Sep 30 12:15:52 animechatapp daphne[509840]: 2023-09-30 12:15:52,134 WARNING  Not Found: /favicon.ico
Oct 01 00:27:38 animechatapp daphne[509840]: Not Found: /favicon.ico
Oct 01 00:27:38 animechatapp daphne[509840]: 2023-10-01 00:27:38,810 WARNING  Not Found: /favicon.ico
Oct 01 00:27:41 animechatapp daphne[509840]: Invalid HTTP_HOST header: 'api.ipify.org'. You may need to add 'api.ipify.org' to ALLOWED_HOSTS.
Oct 01 00:27:41 animechatapp daphne[509840]: Traceback (most recent call last):
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/asgiref/sync.py", line 534, in thread_handler
Oct 01 00:27:41 animechatapp daphne[509840]:     raise exc_info[1]
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 42, in inner
Oct 01 00:27:41 animechatapp daphne[509840]:     response = await get_response(request)
Oct 01 00:27:41 animechatapp daphne[509840]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/django/utils/deprecation.py", line 146, in __acall__
Oct 01 00:27:41 animechatapp daphne[509840]:     response = await sync_to_async(
Oct 01 00:27:41 animechatapp daphne[509840]:                ^^^^^^^^^^^^^^^^^^^^
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/asgiref/sync.py", line 479, in __call__
Oct 01 00:27:41 animechatapp daphne[509840]:     ret: _R = await loop.run_in_executor(
Oct 01 00:27:41 animechatapp daphne[509840]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
Oct 01 00:27:41 animechatapp daphne[509840]:     result = self.fn(*self.args, **self.kwargs)
Oct 01 00:27:41 animechatapp daphne[509840]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/asgiref/sync.py", line 538, in thread_handler
Oct 01 00:27:41 animechatapp daphne[509840]:     return func(*args, **kwargs)
Oct 01 00:27:41 animechatapp daphne[509840]:            ^^^^^^^^^^^^^^^^^^^^^
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/django/middleware/common.py", line 48, in process_request
Oct 01 00:27:41 animechatapp daphne[509840]:     host = request.get_host()
Oct 01 00:27:41 animechatapp daphne[509840]:            ^^^^^^^^^^^^^^^^^^
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/django/http/request.py", line 150, in get_host
Oct 01 00:27:41 animechatapp daphne[509840]:     raise DisallowedHost(msg)
Oct 01 00:27:41 animechatapp daphne[509840]: django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'api.ipify.org'. You may need to add 'api.ipify.org' to ALLOWED_HOSTS.
Oct 01 00:27:41 animechatapp daphne[509840]: 2023-10-01 00:27:41,387 ERROR    Invalid HTTP_HOST header: 'api.ipify.org'. You may need to add 'api.ipify.org' to ALLOWED_HOSTS.
Oct 01 00:27:41 animechatapp daphne[509840]: Traceback (most recent call last):
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/asgiref/sync.py", line 534, in thread_handler
Oct 01 00:27:41 animechatapp daphne[509840]:     raise exc_info[1]
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 42, in inner
Oct 01 00:27:41 animechatapp daphne[509840]:     response = await get_response(request)
Oct 01 00:27:41 animechatapp daphne[509840]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/django/utils/deprecation.py", line 146, in __acall__
Oct 01 00:27:41 animechatapp daphne[509840]:     response = await sync_to_async(
Oct 01 00:27:41 animechatapp daphne[509840]:                ^^^^^^^^^^^^^^^^^^^^
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/home/gamedeveloper/venv/lib/python3.11/site-packages/asgiref/sync.py", line 479, in __call__
Oct 01 00:27:41 animechatapp daphne[509840]:     ret: _R = await loop.run_in_executor(
Oct 01 00:27:41 animechatapp daphne[509840]:               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 01 00:27:41 animechatapp daphne[509840]:   File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run

This output is misleading because I have already added 'api.ipify.org' to my ALLOWED_HOSTS list in my settings.py file and I have restarted all the services like nginx, daphne and gunicorn multiple times but I am still getting this error.

ALLOWED_HOSTS = ['my.ip.address', 'www.aniconnect.org','mail.my-ip-address.cprapid.com','api.ipify.org']

I am unaware of why this is happening. The website was working fine before I got an ssl certificate but the instant I did, the website broke and the chatting functionality of the website broke (mainly that). Please help me out!

0

There are 0 best solutions below