When am trying to connect couch db from java ,am getting following error?

When am trying to connect couch db from java ,am getting following error ?

05-08 07:02:01.310 2608-2646/android.com.eventdriven E/CouchbaseLite/REPLICATOR: {Repl#3} Got LiteCore error: POSIX error 111 “Connection refused”
05-08 07:02:01.431 2608-2608/android.com.eventdriven I/MyActivity: Error code :: 111

Do you really mean CouchDB, as in the Apache CouchDB project? That is not affiliated with Couchbase and is no longer supported in version 2.0+ of Couchbase Lite.

Hi Borrrden,

I have installed sync gateway and couchbase server. Its running in browser
for Eg : if i hit http://localhost:4984/dhaya/ am getting following as output

Also am using following lines of code in android ,it’s showing above error .

// Get the database (and create it if it doesn’t exist).
DatabaseConfiguration config = new DatabaseConfiguration(getApplicationContext());
Database database = null;
try {
database = new Database(“dhaya”, config);
} catch (CouchbaseLiteException e) {

// Create a new document (i.e. a record) in the database.
MutableDocument mutableDoc = new MutableDocument()
.setFloat(“version”, 2.0F)
.setString(“type”, “SDK”);

// Save it to the database.
try {
} catch (CouchbaseLiteException e) {

// Update a document.
mutableDoc = database.getDocument(mutableDoc.getId()).toMutable();
mutableDoc.setString(“language”, “Java”);
try {
} catch (CouchbaseLiteException e) {
Document document = database.getDocument(mutableDoc.getId());
// Log the document ID (generated by the database) and properties
Log.i(TAG, "Document ID :: " + document.getId());
Log.i(TAG, "Learning " + document.getString(“language”));

// Create a query to fetch documents of type SDK.
Query query = QueryBuilder.select(SelectResult.all())
ResultSet result = null;
try {
result = query.execute();
} catch (CouchbaseLiteException e) {
Log.i(TAG, "Number of rows :: " + result.allResults().size());

// Create replicators to push and pull changes to and from the cloud.
Endpoint targetEndpoint = null;
try {
targetEndpoint = new URLEndpoint(new URI(“ws://”));
} catch (URISyntaxException e) {
ReplicatorConfiguration replConfig = new ReplicatorConfiguration(database, targetEndpoint);

// Add authentication.
replConfig.setAuthenticator(new BasicAuthenticator(“dhaya”, “dhaya123”));

// Create replicator.
Replicator replicator = new Replicator(replConfig);

// Listen to replicator change events.
replicator.addChangeListener(new ReplicatorChangeListener() {
public void changed(ReplicatorChange change) {
if (change.getStatus().getError() != null)
Log.i(TAG, "Error code :: " + change.getStatus().getError().getCode());

// Start replication.

The problem is you are not pointing CBL at Sync Gateway.

To be more precise: Port 8091 is Couchbase Server itself, not Sync Gateway. Couchbase Lite cannot communicate directly with Couchbase Server, and in any real installation the Server will be behind a firewall for security reasons.