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

stratboy's avatar

Sail + Scout + Mailisearch: why is my installation not indexing when queue:true and gives errors when queue:false?

Hi, I'm trying scout and meilisearch for the first time. I followed the laracast guide as well as the Scout docs, and the official mailisearch's laravel guide. I managed to have mailisearch recognize the index name, but it's not indexing both when I batch import and when I create a record (Seed in my case). So when I open http://localhost:7700/ I see the mailisearch GUI with 'seeds' as selected index, but there are zero records. There are also a couple of strange facts:

  • As per the Mailisearch's guide, since I'm using Sail, the gui should be at meilisearch:7700 and not localhost:7700. Instead, it's available at localhost:7700 (also evident in docker gui).

  • With scout queue config set to true I can run php artisan scout:import "App\Models\Seed" and it returns:

Imported [App\Models\Seed] models up to ID: 97
All [App\Models\Seed] records have been imported.
  • if I set queue: false, when I import I get this error:
 Illuminate\Database\QueryException 

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: nodename nor servname provided, or not known (Connection: mysql, SQL: select * from `seeds` where `seeds`.`deleted_at` is null order by `seeds`.`id` asc limit 500)
  • With queue:true, I cannot run php artisan scout:flush "App\Models\Seed" since I get the following error, while with queue:false, I can flush:
Meilisearch\Exceptions\CommunicationException 

  cURL error 7: Failed to connect to 127.0.0.1 port 7700 after 0 ms: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://127.0.0.1:7700/indexes/seeds/documents

So,

  • with queue:true I can import but cannot flush, but have nothing indexed in meilisearch.
  • with queue:false I cannot import but cannot import, but can flush.

Any idea?

0 likes
2 replies
LaryAI's avatar
Level 58

It sounds like you're encountering a couple of different issues related to your configuration and environment setup. Let's break down the problems and provide solutions for each.

Problem 1: Meilisearch GUI URL

You mentioned that the Meilisearch GUI is available at localhost:7700 instead of meilisearch:7700. This discrepancy is likely due to how Docker networking is set up in your environment. When using Laravel Sail, services are typically accessible via localhost on the host machine.

Problem 2: Queue Configuration

When queue is set to true, Scout operations are queued and processed by a queue worker. When queue is set to false, operations are executed immediately.

Problem 3: Database Connection Error

The error php_network_getaddresses: getaddrinfo for mysql failed suggests that your application cannot resolve the mysql hostname. This is likely a Docker networking issue.

Problem 4: Meilisearch Connection Error

The error cURL error 7: Failed to connect to 127.0.0.1 port 7700 indicates that your application cannot connect to Meilisearch. This could be due to incorrect configuration or the Meilisearch service not running.

Solutions

Step 1: Verify Docker Services

Ensure all Docker services are running correctly. You can do this by running:

./vendor/bin/sail up

Step 2: Update .env Configuration

Ensure your .env file has the correct configurations for Meilisearch and MySQL. For example:

SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://meilisearch:7700
QUEUE_CONNECTION=database

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password

Step 3: Update config/scout.php

Ensure the queue configuration is set correctly:

'queue' => true,

Step 4: Run Migrations and Seeders

Ensure your database is properly set up and seeded:

./vendor/bin/sail artisan migrate
./vendor/bin/sail artisan db:seed

Step 5: Start Queue Worker

If you have queue set to true, you need to start a queue worker to process the jobs:

./vendor/bin/sail artisan queue:work

Step 6: Import and Flush Data

Try importing and flushing data again:

./vendor/bin/sail artisan scout:import "App\Models\Seed"
./vendor/bin/sail artisan scout:flush "App\Models\Seed"

Additional Debugging

If you still encounter issues, consider the following:

  • Check Docker Logs: Look at the logs for your Docker containers to identify any issues.

    docker-compose logs
    
  • Check Network Configuration: Ensure that your Docker network is set up correctly and that services can communicate with each other.

  • Check Meilisearch Status: Verify that Meilisearch is running and accessible.

    curl http://localhost:7700/health
    

By following these steps, you should be able to resolve the issues with your Scout and Meilisearch setup. If problems persist, consider providing more detailed logs or configuration files for further assistance.

Please or to participate in this conversation.