Unable to connect to couchdb on http://localhost:5984

Successful build (1 month ago):
https://travis-ci.org/scottohara/tvmanager/builds/449081846

Failing build (today):
https://travis-ci.org/scottohara/tvmanager/builds/465811327#L1383

Both builds run on the xcode10 image, and install couchdb from homebrew.

The only notable difference between the two is that the successful build installed couchdb@1.7.1_7 and the latest build installs couchdb@1.7.1_8.

The couchdb server does appears to have started successfully in both builds (see L1082 in the successful build, and L1380 in the failed build)

The point at which the failure occurs is when trying to connect to the couch service on http://localhost:5984. The error is:

Errno::ECONNREFUSED: Connection refused - Connection refused - connect(2) for "localhost" port 5984 (localhost:5984)

Has something changed recently that is preventing http://localhost:5984 from being accessed in the macOS environment? Would using http://127.0.0.1:5984 (instead of localhost) make any difference?

It is not entirely clear to me, but the CouchDB formula did introduce some significant changes. There are additional packages that gets installed with this change (openssl, libtiff, icu4c). Maybe this is significant enough a change.

Additionally, I wonder if CouchDB accepts connections immediately after the “relax” message. I know, for example, that MongoDB needs a little more time when it starts up. Could you try waiting for the port 5984 to open before starting your tests?

Thanks Hiro,

I have such a poor short-term memory. Would you believe we had this exact conversation a couple of years ago? (My apologies, I should have remembered this before I posted here).

Back then, the problem was indeed a packaging issue with the CouchDB formula, which thankfully resolved itself once a new formula was published.

I tried pinning to the same CouchDB formula that was previously used in the successful build:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/32d87008823fc4b38913cc14db29c09c73558f6e/Formula/couchdb.rb

…but even then, it seems to still install those additional dependencies (openssl, libtiff, icu4c) that weren’t there previously.

Anyway, I agree that this more likely to be an issue with the CouchDB formula than with the macOS build environment.

No worries! I didn’t remember this, either, to be quite honest. :slight_smile:

At any rate, do let us know if you find further details. Thank you!

Ah, found it (I removed the -b flag so that couch doesn’t start in background, so that I could see any errors).

Below is the error thrown (appears to be failing to load a library from icu4c):

Apache CouchDB 1.7.1 (LogLevel=info) is starting.

{
  "init terminating in do_boot",
  {
    {
      badmatch,
      {
        error,
        {
          bad_return,
          {
            {
              couch_app,start,
              [
                normal,
                [
                  "/usr/local/etc/couchdb/default.ini",
                  "/usr/local/etc/couchdb/local.ini"
                ]
              ]
            },
            {
              'EXIT',
              {
                {
                  badmatch,
                  {
                    error,
                    {
                      shutdown,
                      {
                        failed_to_start_child,
                        couch_primary_services,
                        {
                          shutdown, 
                          {
                            failed_to_start_child,
                            collation_driver,
                            "dlopen(/usr/local/Cellar/couchdb/1.7.1_7/lib/couchdb/erlang/lib/couch-1.7.1/priv/lib/couch_icu_driver.so, 2): Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib\n
  Referenced from: /usr/local/Cellar/couchdb/1.7.1_7/lib/couchdb/erlang/lib/couch-1.7.1/priv/lib/couch_icu_driver.so\n
  Reason: image not found"
                          }
                        }
                      }
                    }
                  }
                },
                [
                  {
                    couch_server_sup,
                    start_server,
                    1,
                    [
                      {
                        file,
                        "couch_server_sup.erl"
                      },
                      {
                        line,
                        98
                      }
                    ]
                  },
                  {
                    application_master,
                    start_it_old,
                    4,
                    [
                      {
                        file,
                        "application_master.erl"
                      },
                      {
                        line,
                        273
                      }
                    ]
                  }
                ]
              }
            }
          }
        }
      }
    },
    [
      {
        couch,
        start,
        0,
        [
          {
            file,
            "couch.erl"
          },
          {
            line,
            18
          }
        ]
      },
      {
        init,
        start_em,
        1,
        []
      },
      {
        init,
        do_boot,
        3,
        []
      }
    ]
  }
}
init terminating in do_boot ()

The package is compiled to use the dynamic library that’s not found on the system, then?

On my machine which does have the icu4c 62.1 installed, I have that file:

$ ls /usr/local/opt/icu4c/lib/*dylib
/usr/local/opt/icu4c/lib/libicudata.62.1.dylib  /usr/local/opt/icu4c/lib/libicui18n.dylib       /usr/local/opt/icu4c/lib/libicutest.62.dylib    /usr/local/opt/icu4c/lib/libicuuc.62.1.dylib
/usr/local/opt/icu4c/lib/libicudata.62.dylib    /usr/local/opt/icu4c/lib/libicuio.62.1.dylib    /usr/local/opt/icu4c/lib/libicutest.dylib       /usr/local/opt/icu4c/lib/libicuuc.62.dylib
/usr/local/opt/icu4c/lib/libicudata.dylib       /usr/local/opt/icu4c/lib/libicuio.62.dylib      /usr/local/opt/icu4c/lib/libicutu.62.1.dylib    /usr/local/opt/icu4c/lib/libicuuc.dylib
/usr/local/opt/icu4c/lib/libicui18n.62.1.dylib  /usr/local/opt/icu4c/lib/libicuio.dylib         /usr/local/opt/icu4c/lib/libicutu.62.dylib
/usr/local/opt/icu4c/lib/libicui18n.62.dylib    /usr/local/opt/icu4c/lib/libicutest.62.1.dylib  /usr/local/opt/icu4c/lib/libicutu.dylib

Sadly, there is a newer version of icu4c (63.1) available now, so you’ll have to do some magic to install version 62.1 now.

Thanks Hiro.

I’ve managed to workaround this issue (for now) by simply switching to use the homebrew addon, i.e.

before:

before_install:
  - brew update
  - brew install couchdb

after:

addons:
  homebrew:
    packages:
      - couchdb

This currently installs the older 1.7.1_7 version, and without the icu4c issue.

(Hopefully, by the time the Homebrew versions for couchdb and icu4c in the build image are updated, whatever the underlying issues are with these formulas is resolved)

1 Like

Great to hear.