Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

crac's avatar
Level 1

Meilisearch / Scout configuration

I have got Scout working with Meilisearch on my local machine, and I'm now trying to get it working on a test server (Ubuntu / Apache).

I have installed Meilisearch as a service, which is starting up just fine. I'm using meilisearch/meilisearch-php v1.1.1

When I try to create an index (php artisan scout:import "Fully\Qualified\Class\Content") it errors:

Symfony\Component\HttpClient\Psr18RequestException Invalid URL: scheme is missing in "//127.0.0.1:7700/indexes/kAMvu5YrXeu3contents/documents?primaryKey=id". Did you forget to add "http(s)://"?

In my .env file I have the MEILISEARCH_PATH set to http://localhost:7700. In my config/scout.php file the 'host' value is read from the .env file. Nowhere in any of my code do I have the meilisearch host set to 127.0.0.1:7700.

If I create a client object in tinker (reading the host and key values from the .env file rather than hard coding them) it works just fine and I get a meilisearch client object that communicates properly with the meilisearch server.

Any ideas what the problem might be?

0 likes
4 replies
LaryAI's avatar
Level 58

The issue seems to be with the URL format being used by the Meilisearch client. The error message suggests that the URL being used is missing the scheme (http or https).

To fix this, update the MEILISEARCH_PATH value in the .env file to include the scheme. For example, change:

MEILISEARCH_PATH=http://localhost:7700

to:

MEILISEARCH_PATH=http://127.0.0.1:7700

Alternatively, you can update the scout.php configuration file to include the scheme:

'meilisearch' => [
    'host' => env('MEILISEARCH_PATH', 'http://localhost:7700'),
],

to:

'meilisearch' => [
    'host' => env('MEILISEARCH_PATH', 'http://127.0.0.1:7700'),
],

After making these changes, try running the php artisan scout:import command again and see if it works.

crac's avatar
Level 1

Hi,

I have already tried this. The MEILISEARCH_PATH in the .env file and the default value in the env() method in the scout.php file both already have the scheme included, and I have tried with both http://localhost:7700 and http://127.0.0.1:7700 in both places and it makes no difference - the incorrect URL still starts with //127.0.0.1:7700.

This suggests that the config files aren't being read at all, or their values are being overridden somehow.

Just working my way through the error frames to see if I can find where.

newbie360's avatar

@crac

try php artisan config:clear

in the Model toSearchableArray() method, do you have return an primary key column ?

what return by this

$client = new Client(config('scout.meilisearch.host'), config('scout.meilisearch.key'));
$meilisearchIndexes = $client->getIndexes()->getResults();
crac's avatar
Level 1

Hi,

Thanks for your help. After a bit more debugging it turns out that my secure master included a few # characters, which gets identified as a comment in the .env file and so trunctates the key at that character.

Interesting that the error returned bore no relation to the acual problem ...

Anyway, seems to be fixed and indexing now.

Cheers,

Crac

Please or to participate in this conversation.