Unable to connect to MongoDB

I’m trying to get my tests working on the 14.04 image, but I’m having difficulty with the MongoDB connection.

I have some rather unexciting code to connect to the database:

final Datastore datastore = morphia.createDatastore(new MongoClient(""), "applicationname");

And an equally unexciting Circle.yml file:

    version: openjdk8
    - sudo service mongod status || sudo service mongod start
    - mvn clean test

It works fine until the tests actually start (i.e the service starts successfully), but when it tries to connect it throws:

java.lang.RuntimeException: java.net.SocketException: Permission denied
Caused by: java.net.SocketException: Permission denied

The same problem happens when relying on the default instance of MongoDB.

Maybe I am missing something, but I would have thought that MongoDB would be running on the default port on localhost…

Where should my connection be pointing?

1 Like