Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: No suitable servers found - connection refused calling ismaster on '127.0.0.1:27017' #8

Closed
amrithadevadiga22 opened this issue Nov 17, 2020 · 9 comments

Comments

@amrithadevadiga22
Copy link

I have followed these steps

Docker (PHP built-in server)
Clone current repository.
Run once docker build -t mongodb-php-gui . at project's root directory.
Run docker run -it -p 5000:5000 mongodb-php-gui at project's root directory.
Open your browser at this address: http://127.0.0.1:5000/ to access GUI.

i am able access the UI but how to login ? what will be the credentials

@itschrono
Copy link

Hello, if you have a mongo container running you should use his name as host. The other are from the user(s) you created with init script or env variable. If you have only an "admin" user you should omit "Database" so you have access to your others databases.

@amrithadevadiga22
Copy link
Author

HI, i tried to login via admin and gave connection as Host=127.0.0.1 and port=27017 , got error
{
"error": {
"code": 13053,
"message": "No suitable servers found (serverSelectionTryOnce set): [connection refused calling ismaster on '127.0.0.1:27017']"
}
}

note : i checked in host machine that mongo db active and running ..please suggest me what i can do for this..
here i don't have mongo container , i have configured mongo db in dedicated host

@SamuelTallet
Copy link
Owner

Hello. If your MongoDB host is accessible from Internet: use its IP address as host. Else: use 172.17.0.1 as host. Let me know if it works...

@amrithadevadiga22
Copy link
Author

Hi, yes it worked for login, steps i followed like
created a user in mongo cli
and used same user credential and database name in login page with host 172.17.0.1 and port 27017.

but if i try to add user from ui for that DB it is giving me same error " message": "No suitable servers found (serverSelectionTryOnce set): [connection refused calling ismaster on '127.0.0.1:27017']"" please find attachment

and one thing with out giving DB name i am not able to login..so how to login as a admin ? any suggestion for this ?

@SamuelTallet
Copy link
Owner

So when you try to add an user from UI, there's an error? Can you please attach a screenshot?

@amrithadevadiga22
Copy link
Author

Screenshot from 2020-11-18 11-10-06
please find screenshot

after adding query it is not giving result also no error..
Screenshot from 2020-11-18 11-08-16

@SamuelTallet SamuelTallet changed the title Login issue [Docker] connection refused calling ismaster on '127.0.0.1:27017' Nov 18, 2020
@SamuelTallet
Copy link
Owner

@amrithadevadiga22 Hi. Thanks for the screenshots. To bypass the error "The SCRAM_SHA_256 authentication mechanism requires libmongoc built with ENABLE_SSL", follow these steps:

  1. Replace Dockerfile at project's root directory with this one:
FROM php:7.4-cli-alpine
RUN apk update && apk upgrade

# Clone project repository.
RUN apk add --no-cache git
WORKDIR /opt/mongodb-php-gui
RUN git clone https://github.com/SamuelTS/MongoDB-PHP-GUI.git .

# Enable MongoDB PHP ext.
RUN apk add --no-cache autoconf build-base curl-dev openssl-dev
RUN pecl install mongodb-1.8.2 && docker-php-ext-enable mongodb

# Install PHP dependencies.
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install

# Start PHP built-in server.
EXPOSE 5000
CMD ["php", "-S", "0.0.0.0:5000"]
  1. Run again docker build -t mongodb-php-gui . at project's root directory.
  2. Run docker run -it -p 5000:5000 mongodb-php-gui at project's root directory.
  3. Open your browser at this address: http://127.0.0.1:5000/ to access GUI.

Then, about querying, you don't need to write full command db.mycol.find().pretty(). Just write for example { "_id": 1 }.

@amrithadevadiga22
Copy link
Author

@SamuelTS Hi, Thanks for the reply..
i want to know ,what should be user role for a database to perform any operation ..i was getting authentication error for a user with the role "userAdmin" with user name "employee", for db "employee"

and one more thing like i tried some basic mongo db query commands
eg: db.COLLECTIONNAME.findOne()
db.mycol.find({ $and: [ {:}, { :} ] })
db.mycol.find().pretty() etc..

non of the query giving output..as you gave example above like "{ "_id": 1 }", i didn't get how it actually working..and if i want to query the database with some condition how can i write a query !!

@SamuelTallet
Copy link
Owner

SamuelTallet commented Nov 20, 2020

@amrithadevadiga22 Hello.

I suggest you to drop then re-create user named "employee" for db "employee" with role readWrite.
Then logout, login with user "employee". Don't forget to use "employee" db when you fill login form.

You can query database using {} syntax. Input only value passed normally to .find(). Example:

Query

@SamuelTallet SamuelTallet changed the title [Docker] connection refused calling ismaster on '127.0.0.1:27017' [Docker] No suitable servers found - connection refused calling ismaster on '127.0.0.1:27017' Jun 26, 2021
@SamuelTallet SamuelTallet changed the title [Docker] No suitable servers found - connection refused calling ismaster on '127.0.0.1:27017' [Docker] Error: No suitable servers found - connection refused calling ismaster on '127.0.0.1:27017' Jun 26, 2021
@SamuelTallet SamuelTallet changed the title [Docker] Error: No suitable servers found - connection refused calling ismaster on '127.0.0.1:27017' Error: No suitable servers found - connection refused calling ismaster on '127.0.0.1:27017' Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants