Travis-CI build fails due to MongoDB connection timeout

My build started to fail without any changes in the project code, so it looks like a problem with Travis runtime.

My build uses MongoDB to run integration tests:

  - mongodb

and since 2018-12-08, every time the build is run it fails because integration tests can’t connect to MongoDB:

com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=travis-job-b0d8719f-570a-4f48-88a2-1d864ae48787:33492, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by { Connection refused (Connection refused)}}]


I’m a bit confused because I can’t see a way how to get support or report an issue with the Travis-Ci builds when it seems that a problem is not on my side.

MongoDB server appears to start fine. Is it perhaps dying without your knowledge?

Your builds may also fail because of changes in your dependencies as well.

Hi @BanzaiMan, yes, MongoDB service seems to start but I don’t know why it dies or stops listening.

This is a Java/Gradle build, so all my dependencies are fixed and controlled. I have no idea what is changed. I have restarted a build that used to be green and now it fails. says:


whereas in the successful one, it was binding to

If you can, could you try tweaking the MongoDB configuration?

In the mean time, I’ll ask around for possible explanations on our side.


In my build, there is no MongoDB configuration. All I have is the declaration of mongodb service in the .travis.yml

  - mongodb

My integration tests connect to mongodb server using defaults, so they expect the mongodb service to listen on If the mongodb address is changed to travis-job-799337c2-0504-4daf-8374-3f399182937f:42865, definitely my tests won’t be able to connect. It looks like a blocker. Do you know why mongodb address is changed and how to get the defaults back?

Looks like the problem is caused by this big infrastructure migration on Travis-CI

Whatever I do, my integration tests can’t connect to MongoDB.
Moreover, this problem is not caused by the MongoDB service that is launched in the build environment.
I got the same error after switching to Embedded Mongo.

How is your client code connecting to the MongoDB server? mongo is connecting to mongodb:// and getting a response.

Just a standard way in Java:

class MongoIntegrationTest extends JaversMongoRepositoryE2ETest {

    protected MongoDatabase getMongoDb() {
        new MongoClient().getDatabase("j_int_test")

which is equiv to:

new MongoClient('', 27017).getDatabase("j_int_test")

I think it is localhost, not, according to API documentation. Could you try hard coding

already tried :wink:

Hmmm. I am at my wits end. We can enable the debug feature if you’d like to have an interactive session to troubleshoot this further.

let’s try if there is a chance that it would help

It’s enabled now. Please read carefully before starting a debug session. Thanks! might fix the issue with localhost, though not working casts certain amount of doubt.

Could you test again? #1620 might (or might not!) address the underlying issue.

looks like specifying “localhost” is a good workaround, but please give me a while to double check it

@joepvd , @BanzaiMan , the trick with connecting explicitly to localhost works. The build is green now, thanks a lot.