java.io.IOException: couldn't connect to [ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017] bc:java.net.SocketTimeoutException: connect timed out

JIRA | rengith manickam | 3 years ago
  1. 0

    Hi All, 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? Here is error I am getting when I run the program from my local machine... Nov 08, 2013 7:14:04 AM com.mongodb.DBTCPConnector initDirectConnection WARNING: Exception executing isMaster command on ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017 java.io.IOException: couldn't connect to [ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017] bc:java.net.SocketTimeoutException: connect timed out at com.mongodb.DBPort._open(DBPort.java:214) at com.mongodb.DBPort.go(DBPort.java:107) at com.mongodb.DBPort.go(DBPort.java:88) at com.mongodb.DBPort.findOne(DBPort.java:143) at com.mongodb.DBPort.runCommand(DBPort.java:148) at com.mongodb.DBTCPConnector.initDirectConnection(DBTCPConnector.java:548) at com.mongodb.DBTCPConnector.isMongosConnection(DBTCPConnector.java:372) at com.mongodb.Mongo.isMongosConnection(Mongo.java:627) at com.mongodb.DB.wrapCommand(DB.java:294) at com.mongodb.DB.command(DB.java:272) at com.mongodb.DB.command(DB.java:256) at com.mongodb.DB.command(DB.java:313) at com.mongodb.DB.command(DB.java:211) at com.mongodb.DB.command(DB.java:326) Here is my java program: public static void main(String[] args) throws UnknownHostException { Mongo m = new Mongo("ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017"); try { m.getDB("admin").command("ping"); } catch (MongoException.Network e) { // You should get this exception if the server is unavailable e.printStackTrace(); } } Note: I can able to connect mongo db from my terminal using ssh -i key-pair user@servername Could you please tell where to change the firewall setting in amazon ec2 server/is there anything has to do in my local machine? Thanks, Rengith Manickam

    JIRA | 3 years ago | rengith manickam
    java.io.IOException: couldn't connect to [ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017] bc:java.net.SocketTimeoutException: connect timed out
  2. 0

    Hi All, 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? Here is error I am getting when I run the program from my local machine... Nov 08, 2013 7:14:04 AM com.mongodb.DBTCPConnector initDirectConnection WARNING: Exception executing isMaster command on ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017 java.io.IOException: couldn't connect to [ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017] bc:java.net.SocketTimeoutException: connect timed out at com.mongodb.DBPort._open(DBPort.java:214) at com.mongodb.DBPort.go(DBPort.java:107) at com.mongodb.DBPort.go(DBPort.java:88) at com.mongodb.DBPort.findOne(DBPort.java:143) at com.mongodb.DBPort.runCommand(DBPort.java:148) at com.mongodb.DBTCPConnector.initDirectConnection(DBTCPConnector.java:548) at com.mongodb.DBTCPConnector.isMongosConnection(DBTCPConnector.java:372) at com.mongodb.Mongo.isMongosConnection(Mongo.java:627) at com.mongodb.DB.wrapCommand(DB.java:294) at com.mongodb.DB.command(DB.java:272) at com.mongodb.DB.command(DB.java:256) at com.mongodb.DB.command(DB.java:313) at com.mongodb.DB.command(DB.java:211) at com.mongodb.DB.command(DB.java:326) Here is my java program: public static void main(String[] args) throws UnknownHostException { Mongo m = new Mongo("ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017"); try { m.getDB("admin").command("ping"); } catch (MongoException.Network e) { // You should get this exception if the server is unavailable e.printStackTrace(); } } Note: I can able to connect mongo db from my terminal using ssh -i key-pair user@servername Could you please tell where to change the firewall setting in amazon ec2 server/is there anything has to do in my local machine? Thanks, Rengith Manickam

    JIRA | 3 years ago | rengith manickam
    java.io.IOException: couldn't connect to [ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017] bc:java.net.SocketTimeoutException: connect timed out
  3. 0

    Ubuntu mongodb connection is OK on server side but can't be accessed remotely

    Stack Overflow | 2 years ago | adhg
    java.io.IOException: couldn't connect to [/xxx.xxx.xx.xxx:27017] bc:java.net.SocketTimeoutException: connect timed out
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Connection-related exceptions not handled

    GitHub | 3 years ago | kolen
    com.mongodb.MongoException$Network: can't call something : /8.8.8.8:27017/admin
  6. 0

    GitHub comment 41#4637075

    GitHub | 5 years ago | barakm
    com.xebialabs.overthere.cifs.winrm.exception.WinRMRuntimeIOException: Send message on http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com:5985/wsman error , document in <?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> <a:To xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com:5985/wsman</a:To> <a:ReplyTo xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing"> <a:Address mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address> </a:ReplyTo> <w:MaxEnvelopeSize xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" mustUnderstand="true">153600</w:MaxEnvelopeSize> <a:MessageID xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">uuid:64642DF5-0587-4BF1-B653-90C471400F4E</a:MessageID> <w:Locale xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" mustUnderstand="false" xml:lang="en-US"/> <p:DataLocale xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd" mustUnderstand="false" xml:lang="en-US"/> <w:OperationTimeout xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">PT60.000S</w:OperationTimeout> <a:Action xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action> <w:ResourceURI xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" mustUnderstand="true">http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI> <w:OptionSet xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"> <w:Option Name="WINRS_NOPROFILE">FALSE</w:Option> <w:Option Name="WINRS_CODEPAGE">437</w:Option> </w:OptionSet> </env:Header> <env:Body> <rsp:Shell xmlns:rsp="http://schemas.microsoft.com/wbem/wsman/1/windows/shell"> <rsp:InputStreams>stdin</rsp:InputStreams> <rsp:OutputStreams>stdout stderr</rsp:OutputStreams> </rsp:Shell> </env:Body> </env:Envelope> , document out [EMPTY],

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.io.IOException

      couldn't connect to [ec2-XX-XXX-XX-XX.compute-1.amazonaws.com/XX.XXX.XX.XX:27017] bc:java.net.SocketTimeoutException: connect timed out

      at com.mongodb.DBPort._open()
    2. MongoDB Java Driver
      DB.command
      1. com.mongodb.DBPort._open(DBPort.java:214)
      2. com.mongodb.DBPort.go(DBPort.java:107)
      3. com.mongodb.DBPort.go(DBPort.java:88)
      4. com.mongodb.DBPort.findOne(DBPort.java:143)
      5. com.mongodb.DBPort.runCommand(DBPort.java:148)
      6. com.mongodb.DBTCPConnector.initDirectConnection(DBTCPConnector.java:548)
      7. com.mongodb.DBTCPConnector.isMongosConnection(DBTCPConnector.java:372)
      8. com.mongodb.Mongo.isMongosConnection(Mongo.java:627)
      9. com.mongodb.DB.wrapCommand(DB.java:294)
      10. com.mongodb.DB.command(DB.java:272)
      11. com.mongodb.DB.command(DB.java:256)
      12. com.mongodb.DB.command(DB.java:313)
      13. com.mongodb.DB.command(DB.java:211)
      14. com.mongodb.DB.command(DB.java:326)
      14 frames