Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

No suitable servers found (serverSelectionTryOnce set): [connection refused calling ismaster on 'localhost:27017'] #2174

Answered by divine
abdrozak20 asked this question in Q&A
Discussion options

I get this error No suitable servers found (serverSelectionTryOnce set): [connection refused calling ismaster on 'localhost:27017']
I am using laravel 7
and this is config / database.php
'mongodb' => [
'driver' => 'mongodb',
'host' => env('MONGO_DB_HOST', 'localhost'),
'port' => 27017,
'database' => env('MONGO_DB_DATABASE'),
'username' => env('MONGO_DB_USERNAME'),
'password' => env('MONGO_DB_PASSWORD'),
'options' => [
'database' => env('MONGO_DB_DATABASE') // sets the authentication database required by mongo 3
]
],
and this is .env
DB_CONNECTION=mongodb
MONGO_DB_HOST=localhost
MONGO_DB_PORT=27017
MONGO_DB_DATABASE=halosis
MONGO_DB_USERNAME=
MONGO_DB_PASSWORD=

What should i do for resolve that problem.
Thanks in advice:)

You must be logged in to vote

This has nothing to do with this library. You've error that connection is refused.

Double-check that your MongoDB is accessible at that address.

Thanks!

Replies: 1 comment 2 replies

Comment options

This has nothing to do with this library. You've error that connection is refused.

Double-check that your MongoDB is accessible at that address.

Thanks!

You must be logged in to vote
2 replies
Comment options

I try use mongo shell with type this : mongo --host localhost --port 27017
and connected. this is the result
MongoDB shell version v4.4.2
connecting to: mongodb://localhost:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("0e2810f2-d096-4c44-9473-dab053f1e13d") }
MongoDB server version: 4.4.2
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
https://community.mongodb.com

The server generated these startup warnings when booting:
2021年01月02日T04:17:56.191+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
2021年01月02日T04:17:57.256+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted


 Enable MongoDB's free cloud-based monitoring service, which will then receive and display
 metrics about your deployment (disk utilization, CPU, operation statistics, etc).
 The monitoring data will be available on a MongoDB website with a unique URL accessible to you
 and anyone you share the URL with. MongoDB may use this information to make product
 improvements and to suggest MongoDB products and deployment options to you.
 To enable free monitoring, run the following command: db.enableFreeMonitoring()
 To permanently disable this reminder, run the following command: db.disableFreeMonitoring()

What's wrong with my connection. i need help.
thanks

Comment options

Try to use database halosis in mongo shell and insert in test collection and write about result

Answer selected by divine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /