Mongodump连接被拒绝错误:无法建立连接,因为目标计算机主动拒绝了连接。

huangapple go评论76阅读模式
英文:

Mongodump connection refused error: No connection could be made because the target machine actively refused it

问题

I'm trying to backup my local mongodb on windows 11. When I run the monogdump command I get this error:

 mongodump -h localhost --port 21017  -d aws_inventories --username username  --out dump3 --ssl
2023-07-04T10:59:18.460-0400    Failed: can't create session: could not connect to server: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: localhost:21017, Type: Unknown, Last error: connection() error occurred during connection handshake: dial tcp [::1]:21017: connectex: No connection could be made because the target machine actively refused it. }, ] }

That happens after I enter in the password manually.

However I can connect to the database using mongosh:

mongosh
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.5.4
Using MongoDB:          6.0.5
Using Mongosh:          1.5.4

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2023-07-04T09:59:07.616-04: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()
------

Warning: Found ~/.mongorc.js, but not ~/.mongoshrc.js. ~/.mongorc.js will not be loaded.
  You may want to copy or rename ~/.mongorc.js to ~/.mongoshrc.js.

How can I get past this error?

英文:

I'm trying to backup my local mongodb on windows 11. When I run the monogdump command I get this error:

 mongodump -h localhost --port 21017  -d aws_inventories --username username  --out dump3 --ssl
2023-07-04T10:59:18.460-0400    Failed: can't create session: could not connect to server: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: localhost:21017, Type: Unknown, Last error: connection() error occurred during connection handshake: dial tcp [::1]:21017: connectex: No connection could be made because the target machine actively refused it. }, ] }

That happens after I enter in the password manually.

However I can connect to the database using mongosh:

mongosh
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.5.4
Using MongoDB:          6.0.5
Using Mongosh:          1.5.4

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2023-07-04T09:59:07.616-04: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()
------

Warning: Found ~/.mongorc.js, but not ~/.mongoshrc.js. ~/.mongorc.js will not be loaded.
  You may want to copy or rename ~/.mongorc.js to ~/.mongoshrc.js.

How can I get past this error?

答案1

得分: 0

你有一个拼写错误:

mongodump -h localhost --port 21017   # oops.   应该是 27017

mongosh 能正常工作是因为你没有指定任何选项,默认情况下它连接的端口是 27017

英文:

You have a typo:

mongodump -h localhost --port 21017   # oops.   Should be 27017

The reason mongosh works is because you are not specifying any options and by default it is connecting on port 27017.

huangapple
  • 本文由 发表于 2023年7月4日 23:09:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76613924.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定