APP_KEY help please

I could use some help. When I go to my LibreNMS web address I get the below

I SSH into the box and run validate and get the following results
[librenms@servername ~]$ ./validate.php
====================================
Component | Version
--------- | -------
LibreNMS | 21.12.0
DB Schema | 2021_11_29_165436_improve_ports_search_index (229)
PHP | 7.3.20
Python | 3.6.8
MySQL | 10.3.28-MariaDB
RRDTool | 1.7.0
SNMP | 5.8
====================================

[OK]    Composer Version: 2.1.12
[OK]    Dependencies up-to-date.

In EncryptionServiceProvider.php line 101:

  No application encryption key has been specified.

I’m trying to fix this based on what I can find on the community so I ran
[librenms@servername ~]$ ./scripts/composer_wrapper.php install --no-dev
> LibreNMS\ComposerHelper::preInstall
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: fruitcake/laravel-cors
Discovered Package: genealabs/laravel-caffeine
Discovered Package: laravel-notification-channels/webpush
Discovered Package: laravel/tinker
Discovered Package: laravel/ui
Discovered Package: librenms/laravel-vue-i18n-generator
Discovered Package: mews/purifier
Discovered Package: nesbot/carbon
Discovered Package: php-flasher/flasher-laravel
Discovered Package: tightenco/ziggy
Discovered Package: wpb/string-blade-compiler
Package manifest generated successfully.
66 packages you are using are looking for funding.
Use the composer fund command to find out more!
> LibreNMS\ComposerHelper::postInstall
> Illuminate\Foundation\ComposerScripts::postInstall
> @php artisan vue-i18n:generate --multi-locales --format=umd
> @php artisan view:cache
Compiled views cleared!
Blade templates cached successfully!
> @php artisan optimize
Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!
Routes cached successfully!
Files cached successfully!
> @php artisan config:clear
Configuration cache cleared!
> scripts/dynamic_check_requirements.py || pip3 install --user -r requirements.txt || :slight_smile:

it appears everything ran but still same error with ./validate.php

So based on another suggestion I looked at my .env file as librenms user and was looking for APP_KEY but nothing (I thought the script I ran above was suppose to generate it but I could be wrong and probably am since I don’t have any APP_KEY)
[librenms@servername ~]$ cat .env
#DB_HOST=
#DB_DATABASE=
#DB_USERNAME=
#DB_PASSWORD=

DB_HOST=localhost
DB_DATABASE=librenms
DB_USERNAME=librenms
DB_PASSWORD=SuP3R!

#APP_URL=
#INSTALL=true
NODE_ID=619BLAH273
VAPID_PUBLIC_KEY=BNF_ERwfqoBLAHBLAHhmO2Ze28nJw
VAPID_PRIVATE_KEY=70EFmEe5BLAHBLAHGuiYKtBwvhBg

I read something about running this command to generate the key and yet it says its set but where, its not in .env and the website still doesn’t come up.
[librenms@servername ~]$ php artisan key:generate
Application key set successfully.

I’m sure its probably something stupid but would really love to get my LibreNMS back up and running.

It’s running on CentOS 8
[librenms@servername ~]$ uname -r
4.18.0-348.2.1.el8_5.x86_64

Any help is much appreciated

Tried a git pull and got a new error I haven’t seen yet
[librenms@servername ~]$ git pull
bash: git: command not found…
Failed to search for file: Failed to download gpg key for repo ‘epel’: Curl error (37): Couldn’t read a file:// file for file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [Couldn’t open file /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7]

To get the APP_KEY back what I did was edit .env and add the first line as APP_KEY= and save .env then I ran
[librenms@servername ~]$ php artisan key:generate
Application key set successfully.

Did a cat .env and now I see a key

clear the cache by running this command
[librenms@servername ~]$ php artisan config:cache
Configuration cache cleared!
Configuration cached successfully!

Reboot server

log back in and switch to librenms user
su - librenms

[librenms@servername ~]$ ./validate.php

Component Version
LibreNMS 21.12.0
DB Schema 2021_11_29_165436_improve_ports_search_index (229)
PHP 7.3.20
Python 3.6.8
MySQL 10.3.28-MariaDB
RRDTool 1.7.0
SNMP 5.8

====================================

[OK] Composer Version: 2.1.12
[OK] Dependencies up-to-date.
[FAIL] APP_KEY does not match key used to encrypt data. APP_KEY must be the same on all nodes.
[FIX]:
If you rotated APP_KEY, run lnms key:rotate to resolve.
[OK] Database connection successful
[OK] Database schema correct
[FAIL] fping location is incorrect or bin not installed.
[FIX]:
Install fping or manually set the path to fping by placing the following in config.php: $config[‘fping’] = ‘/path/to/fping’;
[WARN] Unable to locate git. This should probably be installed.

So now I’m stuck… any ideas? Does this help at all?

Calling it quits for tonight but here is where I am at…

[librenms@servername ~]$ ./validate.php

Component Version
LibreNMS 21.12.0-4-g4b64d33d1
DB Schema 2021_11_29_165436_improve_ports_search_index (229)
PHP 7.3.20
Python 3.6.8
MySQL 10.3.28-MariaDB
RRDTool 1.7.0
SNMP 5.8

====================================

[OK] Composer Version: 2.1.12
[OK] Dependencies up-to-date.
[FAIL] APP_KEY does not match key used to encrypt data. APP_KEY must be the same on all nodes.
[FIX]:
If you rotated APP_KEY, run lnms key:rotate to resolve.
[OK] Database connection successful
[OK] Database schema correct
[FAIL] fping location is incorrect or bin not installed.
[FIX]:
Install fping or manually set the path to fping by placing the following in config.php: $config[‘fping’] = ‘/path/to/fping’;

[librenms@servername ~]$ ./lnms key:rotate
Either old key or --generate-new-key is required.

[librenms@servername ~]$ ./lnms key:rotate --generate-new-key
Config was cached, cleared cache to make sure APP_KEY is correct. Please re-run lnms key:rotate

[librenms@servername ~]$ ./lnms key:rotate
Either old key or --generate-new-key is required.

So not any closer and just not sure what else I can do on my side. I really need some input from someone who may have run across this before. Anyone? Bueller? :slight_smile:

I thought that php had to be 7.4.x.x

Starting again at it…

[root@servername librenms]# su - librenms

[librenms@servername ~]$ ./validate.php

Component Version
LibreNMS 21.12.0-4-g4b64d33d1
DB Schema 2021_11_29_165436_improve_ports_search_index (229)
PHP 7.3.20
Python 3.6.8
MySQL 10.3.28-MariaDB
RRDTool 1.7.0
SNMP 5.8
====================================

[OK] Composer Version: 2.1.12
[OK] Dependencies up-to-date.
[FAIL] APP_KEY does not match key used to encrypt data. APP_KEY must be the same on all nodes.
[FIX]:
If you rotated APP_KEY, run lnms key:rotate to resolve.
[OK] Database connection successful
[OK] Database schema correct

Following suggestion…
[librenms@servername ~]$ lnms key:rotate
Either old key or --generate-new-key is required.

[librenms@servername~]$ ./lnms key:generate


  • Application In Production!     *
    

Do you really wish to run this command? (yes/no) [no]:

yes

Application key set successfully.

So try and validate again
[librenms@servername ~]$ ./validate.php

Component Version
LibreNMS 21.12.0-4-g4b64d33d1
DB Schema 2021_11_29_165436_improve_ports_search_index (229)
PHP 7.3.20
Python 3.6.8
MySQL 10.3.28-MariaDB
RRDTool 1.7.0
SNMP 5.8
====================================

[OK] Composer Version: 2.1.12
[OK] Dependencies up-to-date.
[FAIL] APP_KEY does not match key used to encrypt data. APP_KEY must be the same on all nodes.
[FIX]:
If you rotated APP_KEY, run lnms key:rotate to resolve.
[OK] Database connection successful
[OK] Database schema correct

Still broke so try another way since the old key is just gone (no idea)

try another approach
[librenms@servername ~]$ ./lnms key:rotate --generate-new-key
Old key: base64:9RXZ2YhNFn6WjTqiifVG9Fv70EQviI3tQRQlOsVXIKw=
New key: base64:xCnwtPd31kaS7vlkzMvcfmxADc3CAmNY/I6ktiKbAtI=
Document BOTH keys! In case something goes wrong set the new key in .env and use the old key as an argument to this command

This command could cause irreversible loss of data and will invalidate all browser sessions. Make sure you have backups.

I have backups and want to continue (yes/no) [no]:

yes

Failed to decrypt validation.encryption.test, skipping
Old key: base64:9RXZ2YhNFn6WjTqiifVG9Fv70EQviI3tQRQlOsVXIKw=
New key: base64:xCnwtPd31kaS7vlkzMvcfmxADc3CAmNY/I6ktiKbAtI=
Failed to decrypt item(s). Set new key as APP_KEY and run this again with the old key as an argument.

NOTE: I know not to share key but this is just temp plus I’m restoring from an old backup since I just can’t seem to figure it out… everyone that has a working LibreNMS should copy that APP_KEY from .env and save it in a safe place because without it you can not decrypt the data.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.