<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:53:41 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-1048] Not able to connect mongo db on ec2 server from standalone Java program</title>
                <link>https://jira.mongodb.org/browse/JAVA-1048</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Hi All,&lt;br/&gt;
      I have installed mongo db on amazon ec2 server, I am trying to connect the db from my local java standalone program. But it throwing exception, I know there is a firewall issue on my server. I am new this amazon ec2 and mongo db. Could anybody help me to resolve this issue?&lt;/p&gt;

&lt;p&gt;Here is error I am getting when I run the program from my local machine...&lt;/p&gt;

&lt;p&gt;Nov 08, 2013 7:14:04 AM com.mongodb.DBTCPConnector initDirectConnection&lt;br/&gt;
WARNING: Exception executing isMaster command on ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017&lt;br/&gt;
java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017&amp;#93;&lt;/span&gt; bc:java.net.SocketTimeoutException: connect timed out&lt;br/&gt;
	at com.mongodb.DBPort._open(DBPort.java:214)&lt;br/&gt;
	at com.mongodb.DBPort.go(DBPort.java:107)&lt;br/&gt;
	at com.mongodb.DBPort.go(DBPort.java:88)&lt;br/&gt;
	at com.mongodb.DBPort.findOne(DBPort.java:143)&lt;br/&gt;
	at com.mongodb.DBPort.runCommand(DBPort.java:148)&lt;br/&gt;
	at com.mongodb.DBTCPConnector.initDirectConnection(DBTCPConnector.java:548)&lt;br/&gt;
	at com.mongodb.DBTCPConnector.isMongosConnection(DBTCPConnector.java:372)&lt;br/&gt;
	at com.mongodb.Mongo.isMongosConnection(Mongo.java:627)&lt;br/&gt;
	at com.mongodb.DB.wrapCommand(DB.java:294)&lt;br/&gt;
	at com.mongodb.DB.command(DB.java:272)&lt;br/&gt;
	at com.mongodb.DB.command(DB.java:256)&lt;br/&gt;
	at com.mongodb.DB.command(DB.java:313)&lt;br/&gt;
	at com.mongodb.DB.command(DB.java:211)&lt;br/&gt;
	at com.mongodb.DB.command(DB.java:326)&lt;/p&gt;

&lt;p&gt;Here is my java program:&lt;/p&gt;

&lt;p&gt;public static void main(String[] args) throws UnknownHostException {&lt;br/&gt;
        Mongo m = new Mongo(&quot;ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017&quot;);&lt;br/&gt;
        try &lt;/p&gt;
{
            m.getDB(&quot;admin&quot;).command(&quot;ping&quot;);
        }
&lt;p&gt; catch (MongoException.Network e) &lt;/p&gt;
{
            // You should get this exception if the server is unavailable
            e.printStackTrace();
        }
&lt;p&gt;    }	&lt;br/&gt;
Note: I can able to connect mongo db from my terminal using ssh -i key-pair user@servername&lt;/p&gt;

&lt;p&gt;Could you please tell where to change the firewall setting in amazon ec2 server/is there anything has to do in my local machine?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Rengith Manickam&lt;/p&gt;</description>
                <environment>Amazon ec2 server</environment>
        <key id="97737">JAVA-1048</key>
            <summary>Not able to connect mongo db on ec2 server from standalone Java program</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="1" iconUrl="https://jira.mongodb.org/images/icons/priorities/blocker.svg">Blocker - P1</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="4">Incomplete</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="rengith">rengith manickam</reporter>
                        <labels>
                            <label>connection</label>
                    </labels>
                <created>Fri, 8 Nov 2013 12:29:59 +0000</created>
                <updated>Wed, 11 Sep 2019 19:11:43 +0000</updated>
                            <resolved>Fri, 8 Nov 2013 13:04:02 +0000</resolved>
                                    <version>2.4</version>
                                                    <component>Authentication</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="453537" author="rengith" created="Fri, 8 Nov 2013 13:13:16 +0000"  >&lt;p&gt;Thanks a lot..Now I can able to connect the database after changing the security group setting. As you mentioned, Hereafter I will use mongodb-user mailinglist or stackoverflow for general questions.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Rengith Manickam.&lt;/p&gt;</comment>
                            <comment id="453531" author="ross@10gen.com" created="Fri, 8 Nov 2013 13:04:02 +0000"  >&lt;p&gt;Hi Rengith,&lt;/p&gt;

&lt;p&gt;You will need to add a security group exception for the port 27017 if you are using default config for you to access it from outside. For security group configuration, please check the amazon EC2 documentation. And if you are using a different port on Mongo, change the security group port accordingly.&lt;/p&gt;

&lt;p&gt;This isn&apos;t an issue in the java driver per sae so for future reference the best place for general questions like this one would be the &lt;a href=&quot;https://groups.google.com/forum/#!forum/mongodb-user&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;mongodb-user mailinglist&lt;/a&gt; or &lt;a href=&quot;http://stackoverflow.com&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;stackoverflow&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;All the best,&lt;/p&gt;

&lt;p&gt;Ross&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hru3iv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>89539</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>