44Connection Troubleshooting
55==========================
66
7+ .. facet::
8+ :name: genre
9+ :values: reference
10+
11+ .. meta::
12+ :keywords: code example, disconnected, deployment
13+
714.. contents:: On this page
815 :local:
916 :backlinks: none
@@ -27,7 +34,7 @@ using the {+driver-long+} to connect to a MongoDB deployment.
2734 questions, discussions, or general technical support
2835
2936Connection Error
30- ~~~~~~~~~~~~~~~~
37+ ----------------
3138
3239The following error message is a general message indicating that the driver
3340cannot connect to a server on the specified hostname or port:
@@ -42,7 +49,7 @@ The following sections describe methods that may help resolve the issue.
4249.. _golang-troubleshooting-connection-string-port:
4350
4451Check Connection String
45- -----------------------
52+ ~~~~~~~~~~~~~~~~~~~~~~~
4653
4754Verify that the hostname and port number in the connection string are both
4855accurate. In the sample error message, the hostname is ``127.0.0.1`` and the
@@ -52,7 +59,7 @@ port is ``27017``. The default port value for a MongoDB instance is
5259.. _golang-troubleshooting-connection-firewall:
5360
5461Configure Firewall
55- ------------------
62+ ~~~~~~~~~~~~~~~~~~
5663
5764Assuming that your MongoDB deployment uses the default port, verify that port
5865``27017`` is open in your firewall. If your deployment uses a different port,
@@ -64,7 +71,7 @@ verify the correct port is open in your firewall.
6471 used by your MongoDB instance.
6572
6673Authentication Error
67- ~~~~~~~~~~~~~~~~~~~~
74+ --------------------
6875
6976The {+driver-short+} can fail to connect to a MongoDB instance if
7077the authorization is not configured correctly. In these cases, the driver raises
@@ -88,7 +95,7 @@ The following sections describe methods that may help resolve the issue.
8895.. _golang-troubleshooting-connection-string-auth:
8996
9097Check Connection String
91- -----------------------
98+ ~~~~~~~~~~~~~~~~~~~~~~~
9299
93100An invalid connection string is the most common cause of authentication
94101issues when attempting to connect to MongoDB.
@@ -110,15 +117,15 @@ are in the correct format.
110117
111118 : / ? # [ ] @
112119
113- When connecting to a replica set, you should include all of the hosts
114- in the replica set in your connection string. Separate each of the hosts
115- in the connection string with a comma. This enables the driver to establish a
116- connection if one of the hosts is unreachable.
120+ When connecting to a replica set, include all the replica set hosts
121+ in your connection string. Separate each of the hosts in the connection
122+ string with a comma. This enables the driver to establish a connection
123+ if one of the hosts is unreachable.
117124
118125.. _golang-troubleshooting-connection-auth-mechanism:
119126
120127Verify the Authentication Mechanism
121- -----------------------------------
128+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122129
123130Ensure that your credentials and authentication mechanism are correct. You can
124131store your authentication credentials in environment variables or you can pass
@@ -130,7 +137,7 @@ To learn more about authentication, see the
130137.. _golang-troubleshooting-connection-admin:
131138
132139Verify User Is in Authentication Database
133- -----------------------------------------
140+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134141
135142To successfully authenticate a connection by using a username and password,
136143the username must be defined in the authentication database. The default
@@ -146,7 +153,7 @@ database:
146153 client := mongo.Connect(uri)
147154
148155Error Sending Message
149- ~~~~~~~~~~~~~~~~~~~~~
156+ ---------------------
150157
151158When the driver fails to send a command after you make a request,
152159it often displays the following general error message:
@@ -159,38 +166,38 @@ it often displays the following general error message:
159166The following sections describe methods that may help resolve the issue.
160167
161168Check Connection String
162- -----------------------
169+ ~~~~~~~~~~~~~~~~~~~~~~~
163170
164171Verify that the connection string in your app is accurate. For more information
165172about verifying your connection string, see
166173:ref:`Connection Error <golang-troubleshooting-connection-string-port>`
167174and :ref:`Authentication Error <golang-troubleshooting-connection-string-auth>`.
168175
169176Verify the Authentication Mechanism
170- -----------------------------------
177+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171178
172179Make sure you are using the correct authentication mechanism and credentials.
173180For more information about authentication errors, see
174181:ref:`Authentication Error <golang-troubleshooting-connection-auth-mechanism>`.
175182
176183Verify User Is in Authentication Database
177- -----------------------------------------
184+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178185
179186Verify the user is in the correct authentication database. For more
180187information about the authentication database, see
181188:ref:`Authentication Error <golang-troubleshooting-connection-admin>`.
182189
183190Configure Firewall
184- ------------------
191+ ~~~~~~~~~~~~~~~~~~
185192
186- The firewall needs to have an open port for communicating with the MongoDB
193+ The firewall must have an open port for communicating with the MongoDB
187194instance. For more information about configuring the firewall, see
188195:ref:`Connection Error <golang-troubleshooting-connection-firewall>`.
189196
190197.. _golang-troubleshooting-connection-number-connections:
191198
192199Check the Number of Connections
193- -------------------------------
200+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194201
195202Each ``MongoClient`` instance supports a maximum number of concurrent open
196203connections in its connection pool. The configuration parameter ``maxPoolSize``
@@ -203,7 +210,7 @@ connection pooling works, see
203210in the FAQ.
204211
205212Timeout Error
206- ~~~~~~~~~~~~~
213+ -------------
207214
208215Sometimes when you send a request through the driver to the server, the request
209216times out. When this happens, you might receive an error message
@@ -218,7 +225,7 @@ If you receive this error, try the following methods to resolve the
218225issue.
219226
220227Set Timeout Option
221- ------------------
228+ ~~~~~~~~~~~~~~~~~~
222229
223230The ``Client`` supports a single ``Timeout`` option that controls the amount of
224231time a single operation can take to execute. You can set this value by using
@@ -234,7 +241,7 @@ connection string option:
234241 client := mongo.Connect(uri)
235242
236243Check the Number of Connections
237- -------------------------------
244+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
238245
239246The number of connections to the server may exceed ``maxPoolSize``. For more
240247information about checking the number of connections, see
0 commit comments