title: Failed to parse MongoDB URI: 'mongodb://'. Invalid host string in URI
body: <p>While trying to run MongoDB 4.0 with laravel I am getting the following error</p>
  
  <blockquote>
    <p>PHP Fatal error:  Uncaught MongoDB\Driver\Exception\InvalidArgumentException: 
    Failed to parse MongoDB URI: 'mongodb://'. Invalid host string in URI. in /var/www/html/valueableapp/valueable_rest_app/api_src/vendor/mongodb/mongodb/src/Client.php:87`</p>
  </blockquote>
  
  <p>I used the command <code>mongo</code> to run the mongo shell and it's working fine.
  also <code>sudo service mongod status</code> and its also showing the status running.
  I am not able to start my project even anyone please. here is the complete stack trace of the issues I am getting 
  php artisan serve --port=8080</p>
  
  <blockquote>
    <p>Laravel development server started: <a href="http://127.0.0.1:8080" rel="nofollow noreferrer">http://127.0.0.1:8080</a>
        [Wed May 22 10:00:54 2019] PHP Fatal error:  Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Failed to parse MongoDB URI: 'mongodb://'. Invalid host string in URI. in /var/www/html/valueable-app/valueable_rest_app/api_src/vendor/mongodb/mongodb/src/Client.php:87
        Stack trace:
        #0 /var/www/html/valueable-app/valueable_rest_app/api_src/vendor/mongodb/mongodb/src/Client.php(87): MongoDB\Driver\Manager->__construct('mongodb://', Array, Array)
        #1 /var/www/html/valueable-app/valueable_rest_app/api_src/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Connection.php(141): MongoDB\Client->__construct('mongodb://', Array, Array)
        #2 /var/www/html/valueable-app/valueable_rest_app/api_src/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/Connection.php(41): Jenssegers\Mongodb\Connection->createConnection('mongodb://', Array, Array)
        #3 /var/www/html/valueable-app/valueable_rest_app/api_src/vendor/jenssegers/mongodb/src/Jenssegers/Mongodb/MongodbServiceProvider.php(30): Jenssegers\Mongodb\Connection->__construct(Array)
        #4 [internal function]: Jenssegers\Mongo in /var/www/html/valueable-app/valueable_rest_app/api_src/vendor/mongodb/mongodb/src/Client.php on line 87</p>
  </blockquote>
  
  <p><strong>Config/database.php</strong></p>
  
  <pre><code>&lt;?php
  
  return [
      'fetch' =&gt; PDO::FETCH_CLASS,
      'default'=&gt;'mongodb',
      'connections' =&gt; array(
  
          'mongodb' =&gt; array(
              'driver'   =&gt; 'mongodb',
              'host'     =&gt; env('DB_HOST'),
              'port'     =&gt; env('DB_PORT'),
              'username' =&gt; env('DB_USERNAME'),
              'password' =&gt; env('DB_PASSWORD'),
              'database' =&gt; env('DB_DATABASE'),
              'options' =&gt; [
                  'database' =&gt; env('DB_DATABASE')
              ]
          ),
  
      ),
      'migrations' =&gt; 'migrations',
      'redis' =&gt; [
  
          'cluster' =&gt; false,
  
          'default' =&gt; [
              'host' =&gt; env('REDIS_HOST', 'localhost'),
              'password' =&gt; env('REDIS_PASSWORD', null),
              'port' =&gt; env('REDIS_PORT', 6379),
              'database' =&gt; 0,
          ],
  
      ],
  
  ];
  </code></pre>
  
  <p><strong>.env</strong></p>
  
  <pre><code>APP_ENV=local
  APP_DEBUG=true
  APP_KEY=base64:q0DOPnhqUzhmMrqryyyN6SDOi6NHKh/BbmJGHw35e3E=
  
  DB_CONNECTION=mongodb
  DB_HOST=localhost
  DB_PORT=27017
  DB_DATABASE=abc
  DB_USERNAME=
  DB_PASSWORD=
  
  
  
  CACHE_DRIVER=array
  SESSION_DRIVER=file
  QUEUE_DRIVER=sync
  
  CRITERIA_MAX_SCORE=5
  CRITERIA_MIN_SCORE=1
  MAX_SCORE_APP=1000
  </code></pre>
  
  <p>Thanks in advance. I have look for the solution on this site<br>
  <a href="https://stackoverflow.com/questions/42533402/laravel-5-2-mongo-monogdb-failed-to-parse-mongodb-uri">Laravel 5.2 Mongo MonogDB Failed to parse MongoDB URI</a>  but this question is not having answer.</p>