First install (core): 404: Not Found

Hi,

I have just installed HA for the first time. As I have another service on my Raspberry Pi, I have performed a Home Assistant Core install. I have got no error on the installation, but I cannot connect to HA in my browser. I have tried:

  • http://homeassistant.local:8123 : This site is not accessible

  • http://localhost:8123/ : 404: Not Found

  • http://127.0.0.1:8123 : 404: Not Found

as suggested in the documentation.

For information, the other service is on 127.0.0.1:80 and is not responding anymore afer HA installation. Here, I get a Error 502: Bad Gateway Error. This service, mycodo, has an nginx configuration listening on ports 80, 443, ssl. So there should be no conflict with HA port 8123.

In my understanding, with the use of ttp://localhost:8123 or http://127.0.0.1:8123 for HA there should be no conflict. However, since I have an nginx setup, does it prevent HA to work as of I configure nginx for it? I am not able to configure nginx myself

Here is what hass has returned to the console:

(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ hass
Unable to find configuration. Creating default one in /home/homeassistant/.homeassistant
2023-02-26 15:47:52.256 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: image_upload
2023-02-26 15:48:27.566 ERROR (MainThread) [homeassistant.setup] Setup failed for analytics: Unable to import component: No module named '_sqlite3'
2023-02-26 15:48:27.570 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of onboarding. Setup failed for dependencies: analytics
2023-02-26 15:48:27.571 ERROR (MainThread) [homeassistant.setup] Setup failed for onboarding: (DependencyError(...), 'Could not setup dependencies: analytics')
2023-02-26 15:48:27.573 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of frontend. Setup failed for dependencies: onboarding
2023-02-26 15:48:27.574 ERROR (MainThread) [homeassistant.setup] Setup failed for frontend: (DependencyError(...), 'Could not setup dependencies: onboarding')
2023-02-26 15:48:27.581 ERROR (MainThread) [homeassistant.setup] Setup failed for recorder: Unable to import component: No module named '_sqlite3'
2023-02-26 16:00:25.758 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: cloud
2023-02-26 16:00:57.898 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of history. Setup failed for dependencies: recorder
2023-02-26 16:00:57.898 ERROR (MainThread) [homeassistant.setup] Setup failed for history: (DependencyError(...), 'Could not setup dependencies: recorder')
2023-02-26 16:00:57.961 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of logbook. Setup failed for dependencies: frontend, recorder
2023-02-26 16:00:57.964 ERROR (MainThread) [homeassistant.setup] Setup failed for logbook: (DependencyError(...), 'Could not setup dependencies: frontend, recorder')
2023-02-26 16:00:57.968 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of map. Setup failed for dependencies: frontend
2023-02-26 16:00:57.970 ERROR (MainThread) [homeassistant.setup] Setup failed for map: (DependencyError(...), 'Could not setup dependencies: frontend')
2023-02-26 16:00:57.973 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of my. Setup failed for dependencies: frontend
2023-02-26 16:00:57.982 ERROR (MainThread) [homeassistant.setup] Setup failed for my: (DependencyError(...), 'Could not setup dependencies: frontend')
2023-02-26 16:00:58.027 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of energy. Setup failed for dependencies: history, recorder
2023-02-26 16:00:58.028 ERROR (MainThread) [homeassistant.setup] Setup failed for energy: (DependencyError(...), 'Could not setup dependencies: history, recorder')
2023-02-26 16:06:57.784 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for stage 2 - moving forward
2023-02-26 16:08:04.896 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: energy, frontend, history, logbook, map, my
2023-02-26 16:08:04.897 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: (DependencyError(...), 'Could not setup dependencies: energy, frontend, history, logbook, map, my')
2023-02-26 16:08:04.939 WARNING (MainThread) [homeassistant.bootstrap] Detected that frontend did not load. Activating safe mode
2023-02-26 16:08:06.126 ERROR (MainThread) [homeassistant.setup] Setup failed for analytics: Unable to import component: No module named '_sqlite3'
2023-02-26 16:08:06.130 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of onboarding. Setup failed for dependencies: analytics
2023-02-26 16:08:06.131 ERROR (MainThread) [homeassistant.setup] Setup failed for onboarding: (DependencyError(...), 'Could not setup dependencies: analytics')
2023-02-26 16:08:06.135 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of frontend. Setup failed for dependencies: onboarding
2023-02-26 16:08:06.137 ERROR (MainThread) [homeassistant.setup] Setup failed for frontend: (DependencyError(...), 'Could not setup dependencies: onboarding')
2023-02-26 16:08:07.060 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of safe_mode. Setup failed for dependencies: frontend
2023-02-26 16:08:07.062 ERROR (MainThread) [homeassistant.setup] Setup failed for safe_mode: (DependencyError(...), 'Could not setup dependencies: frontend')

How should I solve this issue please?

Can you do an (obsolete) netstat -an | grep 8123?
Or ss -a | grep 8123?
To check that HA is well listening to the port.

Should look like
IP v4
tcp LISTEN 0 128 0.0.0.0:8123 0.0.0.0:*
IP v6
tcp LISTEN 0 128 [::]:8123 [::]:*

Can you also do an

ip addr                     

And try to connect with the IP address and :8123?

EDIT Oops, answer to fast. Your HA is not starting
Did you install the requirements specified in the guide?
Are you using the venv?
Are you using python 3.10? Because this is not available out-of-the-box on a RaspberryPi.

The logs mentioned several times that HA can’t import sqlite3. So I’d follow Olivier1974’s suggestion and check prerequisites.

Here it is:

root@raspberrypi:~# netstat -an | grep 8123
tcp        0      0 0.0.0.0:8123            0.0.0.0:*               LISTEN     
tcp6       0      0 :::8123                 :::*                    LISTEN

root@raspberrypi:~# ss -a | grep 8123
tcp               LISTEN                 0                   0                                                                 0.0.0.0:8123                                                              0.0.0.0:*                              
tcp               LISTEN                 0                   0                                                                       *:8123                        

root@raspberrypi:~# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:a6:32:f5:60:40 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.88/24 brd 192.168.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 2a01:e0a:457:7f00:1161:9307:a768:7904/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 86179sec preferred_lft 86179sec
    inet6 fe80::8243:3fd7:4e1d:fd6d/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether dc:a6:32:f5:60:41 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.89/24 brd 192.168.0.255 scope global noprefixroute wlan0
       valid_lft forever preferred_lft forever
    inet6 2a01:e0a:457:7f00:c92f:9802:1636:2da6/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 86179sec preferred_lft 86179sec
    inet6 fe80::fd32:7565:aeb8:3e01/64 scope link 
       valid_lft forever preferred_lft forever

Attempt to connect to http://192.168.0.88:8123/ leads to 404: Not Found

I have followed the guide and installed the dependencies as required, used venv, set python 3.10:

(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ python --version
Python 3.10.10

ok, I am going to check other install instructions for sqlite3 and possibly other things.

sqlite3 is already installed on my RP. Up to now, I don’t find installation tutorials that require other dependencies.

It looks like to be a sqlite3 version compatibility issue.

I’ve no issue, but I had to install Python 3.10.9 and in the venv, sqlite is installing whatever version is needed by HA.
That’s the beauty of a venv, every software its own version of the packages.

I have installed sqlite3 v3.41.0 in /opt/sqlite:

(homeassistant) homeassistant@raspberrypi:~ $ ls -l /opt/sqlite/lib
total 12280
-rw-r--r-- 1 root root 6985348 f�vr. 26 23:07 libsqlite3.a
-rwxr-xr-x 1 root root     983 f�vr. 26 23:07 libsqlite3.la
lrwxrwxrwx 1 root root      19 f�vr. 26 23:07 libsqlite3.so -> libsqlite3.so.0.8.6
lrwxrwxrwx 1 root root      19 f�vr. 26 23:07 libsqlite3.so.0 -> libsqlite3.so.0.8.6
-rwxr-xr-x 1 root root 5575240 f�vr. 26 23:07 libsqlite3.so.0.8.6
drwxr-xr-x 2 root root    4096 f�vr. 26 23:07 pkgconfig

Then I have exported the path:

(homeassistant) homeassistant@raspberrypi:~ $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sqlite/lib

Run hass again, but I have the same issue.

(homeassistant) homeassistant@raspberrypi:~ $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sqlite/lib
(homeassistant) homeassistant@raspberrypi:~ $ hass
2023-02-26 23:15:29.250 ERROR (MainThread) [homeassistant.setup] Setup failed for analytics: Unable to import component: No module named '_sqlite3'

Does HA install itself sqlite in venv? Isn’t venv only for Python?

That’s an excellent question, and unfortunately, I’m not certain.
However, it appears that it installs SQLAlchemy 2.0.4, and from a Python standpoint, it enables the manipulation of the sqlite3 database in the homeassistant directory.

I don’t have any sqlite packages installed otherwise, but I do have numerous apt packages that are incompatible with what HA installs in the venv. In the past, following the venv creation from the installation guide has always resolved my conflicts.

Moreover, I no longer use the sqlite3 DB because it was on the SD card, and I encountered corruption issues previously. Currently, the HA database is on my NAS using MariaDB.

If you have created the venv, then we need to investigate the matter further.

Yes, I did I follow the guide, installed the dependencies and used venv with python 3.10. I am blocked.

I assume that you really need sqlite for something else …
How did you install it?
From sqlite-devel and libsqlite3-dev packages or compiling it?
Did you (re)compile python3.10 after installing it?

For what it’s worth, I don’t have sqlite3 installed but can use the sqlite3 module in the python3.10 venv of HA:

(homeassistant) homeassistant@hassbian:~/.homeassistant $ python3
Python 3.10.9 (main, Feb  2 2023, 09:53:17) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> print(sqlite3.version)
2.6.0

But it is an old version compared to the one you installed.

In your linked post, did you try the solution of exporting the LD_LIBRARY_PATH before starting hass as suggested in post #18

Here is how I built Python 3.10:

# How to Install Python 3.10.7 on the Raspberry Pi - https://aruljohn.com/blog/python-raspberrypi/
sudo su -
wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz
apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev
tar -xzvf Python-3.10.10.tgz
cd Python-3.10.10/
./configure --enable-optimizations
sudo make altinstall
# test
/usr/local/bin/python3.10 -V
	Python 3.10.10

Then venv:

apt-get update
apt-get upgrade -y
apt-get install -y python3 python3-dev python3-venv python3-pip bluez libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 libturbojpeg0-dev tzdata
useradd -rm homeassistant -G dialout,gpio,i2c
mkdir /srv/homeassistant
chown homeassistant:homeassistant /srv/homeassistant
sudo -u homeassistant -H -s
cd /srv/homeassistant
python3.10 -m venv .
source bin/activate
python -m pip install --upgrade pip
python3 -m pip install wheel

Rust was also needed: curl https://sh.rustup.rs -sSf | sh

Then HA following the official procedure for core install : pip3 install homeassistant==2023.2.5

As it was complaining about sqlite3 as already depicted in my former post, I have installed it:

sudo chmod a+wr /opt
cd /opt
wget https://sqlite.org/2023/sqlite-autoconf-3410000.tar.gz
tar -xvf sqlite-autoconf-3410000.tar.gz
cd sqlite-autoconf-3410000
./configure --prefix=/opt/sqlite
make
sudo make install

And finally run hass

My python does not see the sqlite3 module:

(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ python
Python 3.10.10 (main, Feb 26 2023, 09:31:27) [GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/sqlite3/__init__.py", line 57, in <module>
    from sqlite3.dbapi2 import *
  File "/usr/local/lib/python3.10/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'

If I try:


(homeassistant) homeassistant@raspberrypi:/srv/homeassistant $ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sqlite/lib hass
2023-02-28 18:40:10.462 ERROR (MainThread) [homeassistant.setup] Setup failed for analytics: Unable to import component: No module named '_sqlite3'
2023-02-28 18:40:10.521 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of onboarding. Setup failed for dependencies: analytics

hass still complains and the service does not start.

Same with export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sqlite/lib before running hass.

I could not try to edit /etc/systemd/system/[email protected] since I do not have this file.

Even after the LD_LIBRARY_PATH export, python still does not see sqlite3. But what puzzles me is that you say it is not necessary.

I swear that it is not installed on my system, here is a “proof” :slight_smile:

(homeassistant) homeassistant@hassbian:~/.homeassistant $ python3
Python 3.10.9 (main, Feb  2 2023, 09:53:17) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> print(sqlite3.version)
2.6.0
>>>
(homeassistant) homeassistant@hassbian:~/.homeassistant $ which sqlite3
(homeassistant) homeassistant@hassbian:~/.homeassistant $ sqlite3
bash: sqlite3: command not found

I have tried the suggestion of dc125 here unsuccessfully.