英文:
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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论