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