com.mongodb.MongoSocketOpenException: Exception opening socket

GitHub | schorke | 2 months ago
  1. 0

    I want to build a web application on Heroku, I can connect to mongodb, because I tried to create a collection in the Main.java, and it worked. There is the error message: {code} 6:47:08 PM web.1 | [main] INFO org.mongodb.driver.cluster - Cluster created with settings {hosts=[ds015869.mlab.com:15869], mode=SINGLE, requiredClusterTy… 6:47:08 PM web.1 | [main] INFO org.mongodb.driver.cluster - Cluster created with settings {hosts=[127.0.0.1:27017], mode=SINGLE, requiredClusterType=UNKNO… 6:47:08 PM web.1 | [cluster-ClusterId{value='56fda8ece1a1e38897e615c5', description='null'}-127.0.0.1:27017] INFO org.mongodb.driver.cluster - Exception i… 6:47:08 PM web.1 | com.mongodb.MongoSocketOpenException: Exception opening socket 6:47:08 PM web.1 | at com.mongodb.connection.SocketStream.open(SocketStream.java:63) 6:47:08 PM web.1 | at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) 6:47:08 PM web.1 | at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128) 6:47:08 PM web.1 | at java.lang.Thread.run(Thread.java:745) 6:47:08 PM web.1 | Caused by: java.net.ConnectException: Connection refused 6:47:08 PM web.1 | at java.net.PlainSocketImpl.socketConnect(Native Method) 6:47:08 PM web.1 | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) 6:47:08 PM web.1 | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) 6:47:08 PM web.1 | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) 6:47:08 PM web.1 | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 6:47:08 PM web.1 | at java.net.Socket.connect(Socket.java:589) 6:47:08 PM web.1 | at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50) 6:47:08 PM web.1 | at com.mongodb.connection.SocketStream.open(SocketStream.java:58) 6:47:08 PM web.1 | ... 3 more 6:47:08 PM web.1 | [main] INFO org.mongodb.driver.cluster - No server chosen by WritableServerSelector from cluster description ClusterDescription{type=UN… 6:47:09 PM web.1 | [cluster-ClusterId{value='56fda8ece1a1e38897e615c4', description='null'}-ds015869.mlab.com:15869] INFO org.mongodb.driver.connection - … 6:47:09 PM web.1 | [cluster-ClusterId{value='56fda8ece1a1e38897e615c4', description='null'}-ds015869.mlab.com:15869] INFO org.mongodb.driver.cluster - Mon… 6:47:09 PM web.1 | {code}

    JIRA | 8 months ago | Junwei Zhuge
    com.mongodb.MongoSocketOpenException: Exception opening socket
  2. 0

    I want to build a web application on Heroku, I can connect to mongodb, because I tried to create a collection in the Main.java, and it worked. There is the error message: {code} 6:47:08 PM web.1 | [main] INFO org.mongodb.driver.cluster - Cluster created with settings {hosts=[ds015869.mlab.com:15869], mode=SINGLE, requiredClusterTy… 6:47:08 PM web.1 | [main] INFO org.mongodb.driver.cluster - Cluster created with settings {hosts=[127.0.0.1:27017], mode=SINGLE, requiredClusterType=UNKNO… 6:47:08 PM web.1 | [cluster-ClusterId{value='56fda8ece1a1e38897e615c5', description='null'}-127.0.0.1:27017] INFO org.mongodb.driver.cluster - Exception i… 6:47:08 PM web.1 | com.mongodb.MongoSocketOpenException: Exception opening socket 6:47:08 PM web.1 | at com.mongodb.connection.SocketStream.open(SocketStream.java:63) 6:47:08 PM web.1 | at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) 6:47:08 PM web.1 | at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128) 6:47:08 PM web.1 | at java.lang.Thread.run(Thread.java:745) 6:47:08 PM web.1 | Caused by: java.net.ConnectException: Connection refused 6:47:08 PM web.1 | at java.net.PlainSocketImpl.socketConnect(Native Method) 6:47:08 PM web.1 | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) 6:47:08 PM web.1 | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) 6:47:08 PM web.1 | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) 6:47:08 PM web.1 | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 6:47:08 PM web.1 | at java.net.Socket.connect(Socket.java:589) 6:47:08 PM web.1 | at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50) 6:47:08 PM web.1 | at com.mongodb.connection.SocketStream.open(SocketStream.java:58) 6:47:08 PM web.1 | ... 3 more 6:47:08 PM web.1 | [main] INFO org.mongodb.driver.cluster - No server chosen by WritableServerSelector from cluster description ClusterDescription{type=UN… 6:47:09 PM web.1 | [cluster-ClusterId{value='56fda8ece1a1e38897e615c4', description='null'}-ds015869.mlab.com:15869] INFO org.mongodb.driver.connection - … 6:47:09 PM web.1 | [cluster-ClusterId{value='56fda8ece1a1e38897e615c4', description='null'}-ds015869.mlab.com:15869] INFO org.mongodb.driver.cluster - Mon… 6:47:09 PM web.1 | {code}

    JIRA | 8 months ago | Junwei Zhuge
    com.mongodb.MongoSocketOpenException: Exception opening socket
  3. 0

    I have tried the following in an application.yml (from spring-cloud-config), as well as a -D system parameter on startup AND bootstrap.yml to no avail {code} spring.data.mongodb.uri: "mongodb://192.168.1.11:27017/mydb" {code} Yet I keep seeing this in the logs about connecting to 127.0.0.1 and the app fails to boot: {code} 2016-08-23 22:01:01,737 ggsandbox 39380 me-security [t=,s=,se=] INFO [PostProcessorRegistrationDelegate$BeanPostProcessorChecker] Bean 'org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration' of type [class org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration$$EnhancerBySpringCGLIB$$3f8ca239] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2016-08-23 22:01:01,821 ggsandbox 39380 me-security [t=,s=,se=] INFO [cluster] Cluster created with settings {hosts=[localhost:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} 2016-08-23 22:01:01,821 ggsandbox 39380 me-security [t=,s=,se=] INFO [cluster] Adding discovered server localhost:27017 to client view of cluster 2016-08-23 22:01:01,830 ggsandbox 39380 me-security [t=,s=,se=] DEBUG [mbeanserver] ObjectName = org.mongodb.driver:type=ConnectionPool,clusterId=57bcc79d80155499d4df075b,host=localhost,port=27017 2016-08-23 22:01:01,830 ggsandbox 39380 me-security [t=,s=,se=] DEBUG [mbeanserver] name = org.mongodb.driver:type=ConnectionPool,clusterId=57bcc79d80155499d4df075b,host=localhost,port=27017 2016-08-23 22:01:01,830 ggsandbox 39380 me-security [t=,s=,se=] DEBUG [mbeanserver] Send create notification of object org.mongodb.driver:clusterId=57bcc79d80155499d4df075b,host=localhost,port=27017,type=ConnectionPool 2016-08-23 22:01:01,830 ggsandbox 39380 me-security [t=,s=,se=] DEBUG [mbeanserver] JMX.mbean.registered org.mongodb.driver:type=ConnectionPool,clusterId=57bcc79d80155499d4df075b,host=localhost,port=27017 2016-08-23 22:01:01,849 ggsandbox 39380 me-security [t=,s=,se=] INFO [cluster] Exception in monitor thread while connecting to server localhost:27017 com.mongodb.MongoSocketOpenException: Exception opening socket at com.mongodb.connection.SocketStream.open(SocketStream.java:63) at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128) at java.lang.Thread.run(Thread.java:745) Caused by: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50) at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ... 3 common frames omitted {code} The only way I can get it to work is with {code} spring.data.mongodb.host|port{code} in bootstrap.yml or on the command line with -D. Nothing seems to work w/ spring-cloud-config based mongo settings

    Spring JIRA | 3 months ago | bitsofinfo
    com.mongodb.MongoSocketOpenException: Exception opening socket
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Unable to connect to mongodb container using MongoJavaDriver

    Stack Overflow | 4 months ago | tjheslin1
    com.mongodb.MongoSocketOpenException: Exception opening socket
  6. 0

    GitHub comment 144#249810782

    GitHub | 2 months ago | schorke
    com.mongodb.MongoSocketOpenException: Exception opening socket

  1. rp 2 times, last 1 month ago
  2. richard77 2 times, last 7 days ago
  3. treefolk 1 times, last 2 weeks ago
  4. kjhdofjosvs 20 times, last 2 weeks ago
  5. Andreas Häber 9 times, last 2 weeks ago
45 more registered users
49 unregistered visitors
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.net.ConnectException

    Connection refused

    at java.net.PlainSocketImpl.socketConnect()
  2. Java RT
    Socket.connect
    1. java.net.PlainSocketImpl.socketConnect(Native Method)
    2. java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    3. java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    4. java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    5. java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    6. java.net.Socket.connect(Socket.java:589)
    6 frames
  3. MongoDB Java Driver
    DefaultServerMonitor$ServerMonitorRunnable.run
    1. com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50)
    2. com.mongodb.connection.SocketStream.open(SocketStream.java:58)
    3. com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114)
    4. com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128)
    4 frames
  4. Java RT
    Thread.run
    1. java.lang.Thread.run(Thread.java:745)
    1 frame