@@ -26,36 +26,20 @@ using the {+driver-long+} to connect to a MongoDB deployment.
26
26
with MongoDB or the driver, visit the following resources:
27
27
28
28
- The :ref:`Issues & Help <node-issues-help>` page, which has
29
- information about reporting bugs, contributing to the driver, and
30
- finding more resources
29
+ information about how to report bugs, contribute to the driver, and
30
+ find more resources
31
31
- The `MongoDB Community Forums <https://community.mongodb.com>`__ for
32
32
questions, discussions, or general technical support
33
33
34
34
Connection Error
35
35
----------------
36
36
37
- The following error message indicates that the driver cannot connect to a server
38
- on the specified hostname or port. Multiple situations can generate this error
39
- message. In this sample error message, the hostname is ``127.0.0.1`` and the
40
- port is ``27017``:
41
-
42
- .. code-block:: none
43
- :copyable: false
44
-
45
- Error: couldn't connect to server 127.0.0.1:27017
37
+ If the driver cannot connect to the specified host, you might get an
38
+ ``MongoServerSelectionError``.
46
39
47
40
The following sections describe actions you can take to potentially resolve the
48
41
issue.
49
42
50
- .. _node-troubleshooting-connection-string-port:
51
-
52
- Check Your Connection String
53
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54
-
55
- Verify that the hostname and port number in the connection string are both
56
- accurate. The default port value for a MongoDB instance is
57
- ``27017``, but you can configure MongoDB to communicate on another port.
58
-
59
43
.. _node-troubleshooting-connection-firewall:
60
44
61
45
Configure Your Firewall
@@ -64,18 +48,28 @@ Configure Your Firewall
64
48
Verify that the ports your MongoDB deployment listens on are not blocked by a
65
49
firewall on the same network. MongoDB uses port ``27017`` by default. To learn
66
50
more about the default ports MongoDB uses and how to change them, see
67
- :manual:`Default MongoDB Port </reference/default-mongodb-port/>`.
51
+ :manual:`Default MongoDB Port </reference/default-mongodb-port/>` in the
52
+ {+mdb-server+} manual.
68
53
69
54
.. warning::
70
55
71
56
Do not open a port in your firewall unless you are sure it's the port
72
57
used by your MongoDB deployment.
73
58
59
+ Check Your Network Access List
60
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61
+
62
+ Verify that your IP Address is listed in the IP Access List for your cluster.
63
+ You can find your IP Access List in the Network Access section of
64
+ the Atlas UI. To learn more about how to configure your IP Access List,
65
+ see the :atlas:`Configure IP Access List Entries </security/ip-access-list/>`
66
+ guide in the Atlas documentation.
67
+
74
68
ECONNREFUSED Error
75
69
------------------
76
70
77
71
If the connection is refused when the driver attempts to connect to the MongoDB
78
- instance, it generates this error message:
72
+ instance, it generates an error message similar to the following :
79
73
80
74
.. code-block:: none
81
75
:copyable: false
@@ -85,8 +79,8 @@ instance, it generates this error message:
85
79
The following sections describe actions you can take to potentially resolve the
86
80
issue.
87
81
88
- Ensure MongoDB and Your Client Use the Same Protocol
89
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82
+ Ensure MongoDB and Your Client Use the Same IP Address
83
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90
84
91
85
In Node.js v17 and later, the DNS resolver uses ``IPv6`` by default when both
92
86
the client and host support both. For example, if MongoDB uses IPv4 and your
@@ -112,7 +106,7 @@ ECONNRESET Error
112
106
----------------
113
107
114
108
If the connection is reset when the driver calls ``client.connect()``, it
115
- generates this error message:
109
+ generates an error message similar to the following :
116
110
117
111
.. code-block:: none
118
112
:copyable: false
@@ -133,7 +127,9 @@ if the number of connections exceeds this limit.
133
127
You can set the maximum number of connections by setting ``maxPoolSize``. To
134
128
resolve this error, you can decrease the number of maximum allowed connections
135
129
by setting the value of ``maxPoolSize``. Alternatively, you could increase the
136
- file descriptor limit in your operating system.
130
+ file descriptor limit in your operating system. To learn more about how to set
131
+ ``maxPoolSize``, see the API documentation for
132
+ `maxPoolSize <{+api+}/interfaces/MongoClientOptions.html#maxPoolSize>`__ .
137
133
138
134
.. warning::
139
135
@@ -150,8 +146,7 @@ error message similar to one of the following messages:
150
146
.. code-block:: none
151
147
:copyable: false
152
148
153
- Command failed with error 18 (AuthenticationFailed): 'Authentication
154
- failed.' on server <hostname>:<port>.
149
+ MongoServerError: bad auth : authentication failed
155
150
156
151
.. code-block:: none
157
152
:copyable: false
@@ -169,12 +164,13 @@ Check Your Connection String
169
164
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
170
165
171
166
An invalid connection string is the most common cause of authentication
172
- issues when attempting to connect to MongoDB using ``SCRAM-SHA-256``.
167
+ issues when you attempt to connect to MongoDB by using ``SCRAM-SHA-256``.
173
168
174
169
.. tip::
175
170
176
171
For more information about connection strings,
177
- see :ref:`Connection URI <node-connection-uri>` in the Connection Guide.
172
+ see the :ref:`Connection URI <node-connection-uri>` section in the Connection
173
+ Guide.
178
174
179
175
If your connection string contains a username and password, ensure that they
180
176
are in the correct format. If the username or password includes any of the
@@ -216,10 +212,6 @@ database:
216
212
const uri = "mongodb://<db_username>:<db_password>@<hostname>:<port>/?authSource=users";
217
213
const client = new MongoClient(uri);
218
214
219
- You can check if this is the issue by attempting to connect to a MongoDB
220
- instance hosted on the local machine with the same code. A deployment on
221
- the same machine doesn't require any authorization to connect.
222
-
223
215
Error Sending Message
224
216
---------------------
225
217
@@ -271,27 +263,6 @@ For more information about how connection pooling works, see the
271
263
:ref:`Connection Pool Overview <node-faq-connection-pool>`
272
264
in the Connection Pools page.
273
265
274
- Too Many Open Connections
275
- -------------------------
276
-
277
- The driver creates the following error message when it attempts to open a
278
- connection, but it's reached the maximum number of connections:
279
-
280
- .. code-block:: none
281
- :copyable: false
282
-
283
- connection refused because too many open connections
284
-
285
- The following section describes a method that may help resolve the issue.
286
-
287
- Check the Number of Connections
288
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289
-
290
- To create more open connections, increase the value of ``maxPoolSize``. For more
291
- information about checking the number of connections, see
292
- :ref:`Check the Number of Connections <node-troubleshooting-connection-number-connections>`
293
- in the Error Sending Message section.
294
-
295
266
Timeout Error
296
267
-------------
297
268
@@ -313,7 +284,7 @@ Set connectTimeoutMS
313
284
The driver may hang when it's unable to establish a connection because it
314
285
takes too long attempting to reach unreachable replica set nodes. You can limit the
315
286
time the driver spends attempting to establish the connection by using the
316
- ``connectTimeMS `` setting. To learn more about this setting, see the
287
+ ``connectTimeoutMS `` setting. To learn more about this setting, see the
317
288
:manual:`Timeout Options </reference/connection-string/#timeout-options>` in
318
289
the Server manual.
319
290
@@ -331,14 +302,6 @@ The following example sets ``connectTimeoutMS`` to 10000 milliseconds.
331
302
connectTimeoutMS: 10000,
332
303
});
333
304
334
- Check the Number of Connections
335
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
336
-
337
- The number of connections to the server may exceed ``maxPoolSize``. For more
338
- information about checking the number of connections, see
339
- :ref:`Check the Number of Connections <node-troubleshooting-connection-number-connections>`
340
- in the Error Sending Message section.
341
-
342
305
Client Disconnect While Running Operation
343
306
-----------------------------------------
344
307
0 commit comments