No connection to Home Assistant (Nginx Bad Gateway 502)

Dear all,
this is my first post in this forum, so I hope I describe the problem well. If not, let me know.
My computer: Raspberry 4, 4GB on a 64GB SD card
I installed a fresh yunohost version 4.3.6.2 (stable). I created a domain, installed nextcloud on this domain and it works.
I created a subdomain (CNAME to this main domain). I installed Home Assistant on this subdomain. Then I updated Home Assistant to version 2022.2.9~ynh1.
If I try to open the Home Assistant Gui, I get the failure “Bad Gateway 502 Nginx”.
I checked the nginx.conf and also the homeassistant.conf. I opened also the port 8123 on my fritz box.
When I start the diagnosys, it says that the port 8123 is not available from outside (checked this also on dnstools.ch). Also I cannot connect internal to the home assistant (tried with telnet from my windows computer). The port is open (test with: sudo yunohost firewall reload):

If I use wget https://localhost:8123/alive --no-check-certificate the output is:

My nginx.conf:


My homeassistent.conf:

I am thankful for each help!

Hello,
what say the home assistant service ?
You could check in here (https://mydomain.tld/yunohost/admin/#/services/homeassistant) or in console yunohost service log homeassistant.

Hi,
there are a lot of entries. But I cannot read this. Sorry I am a newbie.
The log:
admin@yunohost:~ $ sudo yunohost service log homeassistant
/var/log/homeassistant/homeassistant.log:

  • 2022-02-20 09:34:38 ERROR (MainThread) [homeassistant.setup] Setup failed for cloud: Unable to import component: libffi.so.7: cannot open shared object file: No such file or directory
  • 2022-02-20 09:34:38 ERROR (MainThread) [homeassistant.setup] Setup failed for updater: Unable to import component: libffi.so.7: cannot open shared object file: No such file or directory
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of my. Setup failed for dependencies: frontend
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.setup] Setup failed for my: (DependencyError(…), ‘Could not setup dependencies: frontend’)
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of map. Setup failed for dependencies: frontend
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.setup] Setup failed for map: (DependencyError(…), ‘Could not setup dependencies: frontend’)
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of logbook. Setup failed for dependencies: frontend
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.setup] Setup failed for logbook: (DependencyError(…), ‘Could not setup dependencies: frontend’)
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.loader] Error loading homeassistant.components.hassio. Make sure all dependencies are installed
  • Traceback (most recent call last):
  • File “/var/www/homeassistant/lib/python3.9/site-packages/homeassistant/loader.py”, line 687, in _load_file
  • module = importlib.import_module(path)
    
  • File “/usr/local/lib/python3.9/importlib/init.py”, line 127, in import_module
  • return _bootstrap._gcd_import(name[level:], package, level)
    
  • File “”, line 1030, in _gcd_import
  • File “”, line 1007, in _find_and_load
  • File “”, line 986, in _find_and_load_unlocked
  • File “”, line 680, in _load_unlocked
  • File “”, line 790, in exec_module
  • File “”, line 228, in _call_with_frames_removed
  • File “/var/www/homeassistant/lib/python3.9/site-packages/homeassistant/components/hassio/init.py”, line 50, in
  • from .auth import async_setup_auth_view
    
  • File “/var/www/homeassistant/lib/python3.9/site-packages/homeassistant/components/hassio/auth.py”, line 12, in
  • from homeassistant.auth.providers import homeassistant as auth_ha
    
  • File “/var/www/homeassistant/lib/python3.9/site-packages/homeassistant/auth/providers/homeassistant.py”, line 10, in
  • import bcrypt
    
  • File “/var/www/homeassistant/lib/python3.9/site-packages/bcrypt/init.py”, line 25, in
  • from . import _bcrypt
    
  • ImportError: libffi.so.7: cannot open shared object file: No such file or directory
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.setup] Error during setup of component usb
  • Traceback (most recent call last):
  • File “/var/www/homeassistant/lib/python3.9/site-packages/homeassistant/setup.py”, line 227, in _async_setup_component
  • result = await task
    
  • File “/var/www/homeassistant/lib/python3.9/site-packages/homeassistant/components/usb/init.py”, line 97, in async_setup
  • await usb_discovery.async_setup()
    
  • File “/var/www/homeassistant/lib/python3.9/site-packages/homeassistant/components/usb/init.py”, line 128, in async_setup
  • await self._async_start_monitor()
    
  • File “/var/www/homeassistant/lib/python3.9/site-packages/homeassistant/components/usb/init.py”, line 139, in _async_start_monitor
  • info = await system_info.async_get_system_info(self.hass)
    
  • File “/var/www/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/system_info.py”, line 22, in async_get_system_info
  • "hassio": hass.components.hassio.is_hassio(),
    
  • File “/var/www/homeassistant/lib/python3.9/site-packages/homeassistant/loader.py”, line 762, in getattr
  • raise ImportError(f"Unable to load {comp_name}")
    
  • ImportError: Unable to load hassio
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.setup] Setup failed for mobile_app: Unable to import component: libffi.so.7: cannot open shared object file: No such file or directory
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: cloud, frontend, logbook, map, mobile_app, my, usb, updater
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: (DependencyError(…), ‘Could not setup dependencies: cloud, frontend, logbook, map, mobile_app, my, usb, updater’)
  • 2022-02-20 09:34:39 WARNING (MainThread) [homeassistant.bootstrap] Detected that frontend did not load. Activating safe mode
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.auth.providers] Unable to load auth provider homeassistant: libffi.so.7: cannot open shared object file: No such file or directory
  • 2022-02-20 09:34:39 ERROR (MainThread) [homeassistant.bootstrap] Home Assistant core failed to initialize. Further initialization aborted
    journalctl:
  • – Logs begin at Fri 2022-02-18 17:20:23 GMT, end at Sun 2022-02-20 14:47:11 GMT. –
  • Feb 18 17:20:41 systemd[1]: Started Home Assistant.
  • Feb 20 09:32:20 systemd[1]: Stopping Home Assistant…
  • Feb 20 09:32:31 systemd[1]: homeassistant.service: Succeeded.
  • Feb 20 09:32:31 systemd[1]: Stopped Home Assistant.
  • Feb 20 09:34:17 systemd[1]: Started Home Assistant.
  • Feb 20 09:34:24 systemd[1]: homeassistant.service: Current command vanished from the unit file, execution of the command list won’t be resumed.
  • Feb 20 09:34:24 systemd[1]: Stopping Home Assistant…
  • Feb 20 09:34:35 systemd[1]: homeassistant.service: Succeeded.
  • Feb 20 09:34:35 systemd[1]: Stopped Home Assistant.
  • Feb 20 09:34:35 systemd[1]: Started Home Assistant.
    admin@yunohost:~ $

Hi,
after reading the log more carefully I found out the problem is python 3.9.
Therefore I needed to install the libff7.so manually.
I used the following commands:
wget “https://github.com/libffi/libffi/releases/download/v3.3/libffi-3.3.tar.gz
tar zxf libffi-3.3.tar.gz
cd libffi-3.3
./configure
sudo make install
sudo ldconfig

Now it works fine!

Thanks to ewilly with the service.log command. You helped me a lot!!!

Thanks to you, the package was updated to include the building of libff if needed (buster)