'WordPress "Notice: Undefined index: host" after initial setup running locally on linux

I'm trying to set up WordPress on my laptop running Kali Linux. Everything works until I install WordPress and the theme I am using. I'm trying to use roots sage on bedrock. But after I get through the installation process I get a notice in the admin:

Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2937
Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2937
Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2999
Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2999

And in the frontend:

Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2999
Notice: Undefined index: host in /var/www/html/site/web/wp/wp-includes/theme.php on line 2999

Can anyone explain why I'm getting these notices? I must have missed something but I've gone through the instructions several times and I'm out of ideas. Thanks



Solution 1:[1]

You can define WP_HOME & WP_SITEURL in wp-config.php

define('WP_HOME','http://localhost/project_folder_name');
define('WP_SITEURL','http://localhost/project_folder_name');

Solution 2:[2]

This can also be caused by an error with the siteurl and home options in wp_options table.

Make sure the url's have a host as well, http://example.com not just example.com.

Solution 3:[3]

I just now came across this and for me, switching back from PHP 8.x.x to PHP 7.x.x resolved the issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Prashant Suthar
Solution 2 Mugur 'Bud' Chirica
Solution 3 chrisi1698