No buffer space available (maximum connections reached?): connect

Hi We are trying to insert around 10000 Documents to a MongoDB’s Collection. The data is basically read from the CSV file and stored into MongoDB local instance. Near to 8300 records got inserted and beyond this, we get the following error

07-10-2020 16:26:52.739 [main] INFO  org.mongodb.driver.cluster.info - Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms'}
07-10-2020 16:26:52.740 [main] INFO  org.mongodb.driver.cluster.info - Cluster description not yet available. Waiting for 30000 ms before timing out
07-10-2020 16:26:52.777 [cluster-ClusterId{value='5f7d9ef436efac69854c9165', description='null'}-localhost:27017] INFO  org.mongodb.driver.cluster.info - Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
	at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:70)
	at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:127)
	at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): connect
	at java.net.DualStackPlainSocketImpl.connect0(Native Method)
	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:83)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

Was this the only thing connecting to your database at the time ?

Thanks for the reply Chris, Actually trying to read an Excel which has around 40000 records or rows, we wanted to insert these rows into MongoDB as a document and while doing so I am getting this error after storing 8100 records…

Was this the only thing connecting to your database at the time ?