Skip to content

Commit 9f92d14

Browse files
author
Chris Cho
authored
DOCSP-17791: update instructions on connecting to locally hosted server (#235)
* DOCSP-17791: update instructions on connecting to locally hosted server
1 parent 9f8387d commit 9f92d14

File tree

4 files changed

+54
-20
lines changed

4 files changed

+54
-20
lines changed

source/fundamentals/connection.txt

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Connection Guide
55
.. contents:: On this page
66
:local:
77
:backlinks: none
8-
:depth: 2
8+
:depth: 3
99
:class: singlecol
1010

1111
This guide shows you how to connect to a MongoDB instance or replica set
@@ -53,20 +53,34 @@ options as parameters. In the example above, we set two connection options:
5353
``poolSize=20`` and ``writeConcern=majority``. For more information on connection
5454
options, skip to the :ref:`connection-options` section.
5555

56+
.. _connect-atlas-node-driver:
57+
5658
The code below shows how you can use the sample connection URI in a client to
5759
connect to MongoDB.
5860

5961
.. literalinclude:: /code-snippets/connection/srv.js
6062
:language: javascript
6163

62-
Connect to ``localhost``
63-
++++++++++++++++++++++++
64+
.. _node-other-ways-to-connect:
65+
66+
Other Ways to Connect to MongoDB
67+
--------------------------------
68+
69+
If you are connecting to a single MongoDB server instance or replica set
70+
that is not hosted on Atlas, see the following sections to find out how to
71+
connect.
72+
73+
Connect to a MongoDB Server on Your Local Machine
74+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6475

6576
.. include:: /includes/localhost-connection.rst
6677

67-
------------------------
78+
To test whether you can connect to your server, replace the connection
79+
string in the :ref:`Connect to MongoDB Atlas <connect-atlas-node-driver>` code
80+
example and run it.
81+
6882
Connect to a Replica Set
69-
------------------------
83+
^^^^^^^^^^^^^^^^^^^^^^^^
7084

7185
A MongoDB replica set deployment is a group of connected instances that
7286
store the same set of data. This configuration of instances provides data
Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
To connect to a ``mongod`` running locally, change the connection string
2-
to ``"mongodb://localhost:<port>"``, e.g. ``"mongodb://locahost:27017"``.
3-
4-
Your ``mongod`` instance must be running to successfully connect to your
5-
database. For information on how to start your ``mongod`` instance,
6-
see the :manual:`Manage mongod Processes
7-
</tutorial/manage-mongodb-processes/#start-mongod-processes>` Server
8-
Manual Entry.
1+
If you need to run a MongoDB server on your local machine for development
2+
purposes instead of using an Atlas cluster, you need to complete the following:
3+
4+
1. Download the `Community <https://www.mongodb.com/try/download/community>`__
5+
or `Enterprise <https://www.mongodb.com/try/download/enterprise>`__ version
6+
of MongoDB Server.
7+
8+
#. `Install and configure <https://docs.mongodb.com/manual/installation/>`__
9+
MongoDB Server.
10+
11+
#. Start the server.
12+
13+
.. important::
14+
15+
Always secure your MongoDB server from malicious attacks. See our
16+
:manual:`Security Checklist </administration/security-checklist/>` for a
17+
list of security recommendations.
18+
19+
After you successfully start your MongoDB server, specify your connection
20+
string in your driver connection code.
21+
22+
If your MongoDB Server is running locally, you can use the connection string
23+
``"mongodb://localhost:<port>"`` where ``<port>`` is the port number you
24+
configured your server to listen for incoming connections.
25+
26+
If you need to specify a different hostname or IP address, see our Server
27+
Manual entry on :manual:`Connection Strings </reference/connection-string/>`.

source/quick-start.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ includes information on the hostname or IP address and port of your
119119
instance, authentication mechanism, user credentials when applicable, and
120120
other connection options.
121121

122+
If you are connecting to an instance or cluster that is not hosted by Atlas,
123+
see :ref:`Other Ways to Connect to MongoDB <node-other-ways-to-connect>` for
124+
instructions on how to format your connection string.
125+
122126
To retrieve your connection string for the instance and user you created in
123127
the previous step, log into your Atlas account and navigate to the
124128
**Clusters** section and click the **Connect** button for the cluster that you
@@ -212,11 +216,6 @@ After completing this step, you should have a working application that uses
212216
the Node.js driver to connect to your MongoDB instance, run a query on the
213217
sample data, and prints out the result.
214218

215-
Connect to ``localhost``
216-
------------------------
217-
218-
.. include:: /includes/localhost-connection.rst
219-
220219
Next Steps
221220
----------
222221

source/whats-new.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ What's New in 4.1
2323

2424
New features of the 4.1 Node.js driver release include:
2525

26-
- Added support for load balancer support to use in the beta :atlas:`Serverless platform </choose-database-deployment-type/>`
27-
- Added support for the ``advanceClusterTime()`` method to determine if the ``ClientSession`` should update its cluster time
26+
- Added load balanced connection support for all cluster types including
27+
the beta :atlas:`Serverless platform </choose-database-deployment-type/?tck=docs_driver_nodejs>`.
28+
- Added support for the ``advanceClusterTime()`` method to determine if
29+
the ``ClientSession`` should update its cluster time.
2830

2931
.. _version-4.0:
3032

0 commit comments

Comments
 (0)