title: Problem with the configuration of the Ktor server for Kmongo (Kotlin Server + Mongo)
body: <p><strong>I'm using Ktor with KMongo</strong>. I have a problem when I start the server in localhost and I make a simple <strong>'get' request</strong>. The references aren't  very clear and complete - <a href="https://litote.org/kmongo/" rel="nofollow noreferrer">https://litote.org/kmongo/</a> - regarding the configuration of the database on the server.
  Does anyone know how to solve the problem? I think it's a simple configuration problem, but I do not know how to solve it. <strong>I'm not using Spring.</strong></p>
  
  <p>This is the code for the connection to the KmongoDB :</p>
  
  <pre><code>package com.progettoetere.Routes
  
  import io.ktor.application.
  import io.ktor.response.respondText
  import io.ktor.routing.*
  import kotlinx.coroutines.runBlocking
  
  import org.litote.kmongo.eq
  import org.litote.kmongo.reactivestreams.*
  import org.litote.kmongo.coroutine.*
  
  fun Route.survey(){
  
      //ramo per i survey
      route("/survey"){
  
          //ritorno tutti i questionari
          get("/"){
  
  
  
                          val client = KMongo.createClient().coroutine //client whit Kotli coroutines
                          val database = client.getDatabase("test") //get a test database
                          val colSurvey = database.getCollection&lt;Survey&gt;() //get the collection of surveys
  
                          //start coroutine
                          runBlocking {
  
                              //get one survey for DEBUG with id == 1023
                              val dato: Survey? = colSurvey.findOne(Survey::id_survey eq 1023)
  
                              //check the survey
                              if (dato != null) {
                                  call.respondText { "The survey is present" }
                              } else {
                                  call.respondText { "The survey is not present" }
                              }
                          }
  
  }
  </code></pre>
  
  <p>The error occurs when I create the client instance :</p>
  
  <blockquote>
    <p>val client = KMongo.createClient().coroutine</p>
  </blockquote>
  
  <p>This is the stack error :</p>
  
  <pre><code>2019-03-11 20:58:22.334 [main] INFO  Application - Responding at http://0.0.0.0:8080
  2019-03-11 20:58:27.633 [nettyCallPool-4-1] INFO  org.mongodb.driver.cluster - Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
  2019-03-11 20:58:27.655 [nettyCallPool-4-1] DEBUG org.mongodb.driver.cluster - Updating cluster description to  {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]
  2019-03-11 20:58:27.666 [cluster-ClusterId{value='5c86bde3cad88d4f128ae82c', description='null'}-localhost:27017] DEBUG org.mongodb.driver.connection - Closing connection connectionId{localValue:1}
  2019-03-11 20:58:27.668 [cluster-ClusterId{value='5c86bde3cad88d4f128ae82c', description='null'}-localhost:27017] INFO  org.mongodb.driver.cluster - Exception in monitor thread while connecting to server localhost:27017
  com.mongodb.MongoSocketOpenException: Exception opening socket
      at com.mongodb.internal.connection.AsynchronousSocketChannelStream$OpenCompletionHandler.failed(AsynchronousSocketChannelStream.java:117)
      at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:128)
      at sun.nio.ch.Invoker$2.run(Invoker.java:218)
      at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: java.net.ConnectException: Connessione rifiutata
      at sun.nio.ch.UnixAsynchronousSocketChannelImpl.checkConnect(Native Method)
      at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishConnect(UnixAsynchronousSocketChannelImpl.java:252)
      at sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:198)
      at sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:213)
      at sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:293)
  </code></pre>