benweet/stackedit · error · Error

${dbUrl} is not accessible. Make sure you have the proper pe

Error message

${dbUrl} is not accessible. Make sure you have the proper permissions.

What it means

During CouchDB workspace initialization, the provider makes a request to the workspace database URL (dbUrl) and, if that request fails, it discards the underlying CouchDB error and throws this message from src/services/providers/couchdbWorkspaceProvider.js:58. It means the app could not reach or authenticate against the CouchDB database that backs the workspace. The real cause (network failure, 401, missing CORS headers, nonexistent DB) is hidden in the caught exception.

Source

Thrown at src/services/providers/couchdbWorkspaceProvider.js:58

        dbUrl,
      });
    }

    // Create the workspace if it doesn't exist
    if (!store.getters['workspace/workspacesById'][workspaceId]) {
      try {
        // Make sure the database exists and retrieve its name
        const db = await couchdbHelper.getDb(store.getters['data/couchdbTokensBySub'][workspaceId]);
        store.dispatch('workspace/patchWorkspacesById', {
          [workspaceId]: {
            id: workspaceId,
            name: db.db_name,
            providerId: this.id,
            dbUrl,
          },
        });
      } catch (e) {
        throw new Error(`${dbUrl} is not accessible. Make sure you have the proper permissions.`);
      }
    }

    badgeSvc.addBadge('addCouchdbWorkspace');
    return store.getters['workspace/workspacesById'][workspaceId];
  },
  async getChanges() {
    const syncToken = store.getters['workspace/syncToken'];
    const lastSeq = store.getters['data/localSettings'].syncLastSeq;
    const result = await couchdbHelper.getChanges(syncToken, lastSeq);
    const changes = result.changes.filter((change) => {
      if (!change.deleted && change.doc) {
        change.item = change.doc.item;
        if (!change.item || !change.item.id || !change.item.type) {
          return false;
        }
        // Build sync data
        change.syncData = {

View on GitHub (pinned to 6dce2a5e36)

Solutions

  1. Verify the CouchDB URL is reachable (curl <dbUrl>) and the database exists.
  2. Check CouchDB/CORS: enable CORS for the app origin (e.g. via add_cors in Fauxton) and allow credentials if needed.
  3. Confirm credentials/permissions on the database (read/write for the user).
  4. Inspect the original caught error (network tab) to distinguish DNS/connection vs 401/404.

Example fix

// before
} catch (e) {
  throw new Error(`${dbUrl} is not accessible. Make sure you have the proper permissions.`);
}
// after
} catch (e) {
  throw new Error(`${dbUrl} is not accessible. Make sure you have the proper permissions. (${e && e.message})`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

async function couchdbReachable(dbUrl) {
  try {
    const res = await fetch(dbUrl, { method: 'GET' });
    return res.ok || res.status === 401;
  } catch (e) {
    return false; // network/CORS failure
  }
}

Type guard

function isPermissionError(err) {
  return err && (err.status === 401 || err.status === 403 || /permission|unauthorized/i.test(err.message || ''));
}

Try / catch

try {
  await provider.initWorkspace(...);
} catch (err) {
  if (/not accessible/.test(err.message)) {
    promptUserToCheckCouchdbUrlAndCors(err);
  }
}

Prevention

When it happens

Trigger: The HTTP request against dbUrl inside initWorkspace throws: server unreachable, wrong dbUrl/host, invalid credentials, database deleted, or CORS blocking the browser request.

Common situations: Typing the wrong CouchDB URL when adding a workspace; CouchDB requiring auth for the DB; CouchDB not sending CORS headers so the browser request fails; reverse proxy or firewall blocking the endpoint.

Related errors


AI-assisted analysis of benweet/stackedit@6dce2a5e36 (2026-09-01). Data as JSON: /api/errors/4ad77d342f087fbf. Report an issue: GitHub.