arunbandari / mongo-gui

A web-based MongoDB graphical user interface
http://20.106.238.56:4321/
MIT License
290 stars 87 forks source link

Deploying on Server - MongoParseError #54

Closed SteveFirsake closed 3 years ago

SteveFirsake commented 3 years ago

Hi Arun,

This has to be best piece of GUI for Mongo I have seen ever.

kudos for the great work - have to buy you coffee sometime soon.

So there is this section you mention in your documentation:

Installed via npm:

mongo-gui -u mongodb+srv://<username>:<password>@host/<dbnames>?retryWrites=true&w=majority

I'd like to execute this line as this:

mongo-gui -u mongodb+srv://steve:mi%23llion@localhost:27071/chickendb?retryWrites=true&w=majority

Which should open a port 4321 where I can view from my server e.g. http:32.66.74.32:4321

But I keep getting this error:

Failed to connect mongoDB - MongoParseError: URI does not have hostname, domain name and tld

Kindly tell me what I am doing wrong.

arunbandari commented 3 years ago

@SteveFirsake Thank you for the kind words.

and assuming you're trying to run this on a remote server and want to connect to the MongoDB installed on the same instance. If so, then this should work: mongo-gui -u mongodb://<username>:<password>@localhost:27017 or mongo-gui -u mongodb://localhost:27017

i.e mongo-gui -u mongodb://steve:mi%23llion@localhost:27071

Let me know if that doesn't work

SteveFirsake commented 3 years ago

Thanks for your quick response.

This is what I am getting as a response now:

Failed to connect mongoDB - MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27071

I have confirmed that mongod is indeed running and I can access the DB with my credentials

I wonder if I have to set my conf file to 32.66.74.32 instead of 127.0.0.1

Kindly advise :)

arunbandari commented 3 years ago

@SteveFirsake can you try to connect to your remote MongoDB instance from your local machine and see whether that works? eg mongo-gui -u mongodb://host:port

SteveFirsake commented 3 years ago

Hi,

It takes long and times out.

My idea was, providing a link by the end of the day sort of like http:32.66.74.32/mongo-gui that will be used to access the mongo-gui that is installed on the server.

I see you did the same with the heroku link example. How did you achieve this?

I would like to do the same on my private server, ubuntu - using AWS.

SteveFirsake commented 3 years ago

Hello @arunbandari ,

mongo-gui

By itself works on my server by opening up a browser. It is using the admin user who can edit many thing :(

So I created a user that only has "find" or "read" roles :)

I tried:

mongo-gui -u mongodb://localhost:27017/powerless_user -p 4321

On the server so that I can get it to fire up an instance for exploring in a browser. For that user. But I get this error:

`events.js:167 throw er; // Unhandled 'error' event ^

Error: listen EADDRINUSE :::4321 at Server.setupListenHandle [as _listen2] (net.js:1286:14) at listenInCluster (net.js:1334:12) at Server.listen (net.js:1421:7) at Function.listen (/home/steve/.nvm/versions/node/v10.13.0/lib/node_modules/mongo-gui/node_modules/express/lib/application.js:618:24) at Function.app.once (/home/steve/.nvm/versions/node/v10.13.0/lib/node_modules/mongo-gui/server.js:47:7) at Object.onceWrapper (events.js:273:13) at Function.emit (events.js:182:13) at InitDB.mongoClient.connect.then.client (/home/steve/.nvm/versions/node/v10.13.0/lib/node_modules/mongo-gui/src/db/dataAccessAdapter.js:27:24) at process._tickCallback (internal/process/next_tick.js:68:7) Emitted 'error' event at: at emitErrorNT (net.js:1313:8) at process._tickCallback (internal/process/next_tick.js:63:19)`

SteveFirsake commented 3 years ago

It worked!!

This is what I did - let me leave this here for future reference to others:

  1. Open mongo on your server via the terminal

  2. Mongo will print out a line with the link you need to use e.g. mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb

  3. Use this for the -u tag. In my case I had to remove compressors section and user:password@127.0.0.1... at the beginning of the URL.

Now all that is left is to figure out how to automate this step by default - not having to run to the terminal over and over again.

Also note - your user may need a root role: https://stackoverflow.com/questions/23943651/mongodb-admin-user-not-authorized