Unable to connect to DB (No suitable servers found)

Created on 19 June 2024, 10 months ago

Problem/Motivation

After installing MongoDB extension and enabled MongoDB/mongodb_watchdog modules, getting below error.

MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling hello on 'localhost:27017'] in MongoDB\Driver\Manager->selectServer() (line 599 of /var/www/vendor/mongodb/mongodb/src/functions.php).

Steps to reproduce

  1. Followed Steps to install MongoDB in my docker (https://hub.docker.com/_/mongo)
  2. After successful installation checked PHP info for MongoDB and its enabled
  3. Downloaded and Enabled MongoDB modules along with MongoDB watchdog
  4. Going to Status reports page gives error
πŸ› Bug report
Status

Postponed: needs info

Version

2.1

Component

Watchdog (logger)

Created by

πŸ‡ΊπŸ‡ΈUnited States ajay_reddy Alpharetta, Georgia, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ajay_reddy
  • πŸ‡ΊπŸ‡ΈUnited States ajay_reddy Alpharetta, Georgia, USA
  • πŸ‡ΊπŸ‡ΈUnited States ajay_reddy Alpharetta, Georgia, USA
  • Status changed to Postponed: needs info 10 months ago
  • πŸ‡«πŸ‡·France fgm Paris, France

    AFAICS this means your PHP cannot see your MongoDB server.

    Since your phpinfo() shows the extension is installed in your PHP, the likely culprit is the DSN you are using localhost:27017.

    Did you copy and adapt the example.settings.local.php provided by the module to your actual topology ?

    Try to enter the container in which you are running PHP (possibly the same one as apache) and run mongosh to check if it can indeed connect to your mongodb server. I suspect you need to use the name of the container instead of localhost.

Production build 0.71.5 2024