juicedata/juicefs · error

Can't create connection to cluster %s for user %s: %s

Error message

Can't create connection to cluster %s for user %s: %s

What it means

newCeph creates a RADOS connection handle via go-ceph's rados.NewConnWithClusterAndUser(cluster, user). If the connection object cannot be created (bad cluster/user parameter combos, missing ceph libraries/config), construction fails with this message.

Source

Thrown at pkg/object/ceph.go:341

			conds[j].Signal()
			ms[j].Unlock()
		}
	}()
	return objs, nil
}

func newCeph(endpoint, cluster, user, token string) (ObjectStorage, error) {
	if !strings.Contains(endpoint, "://") {
		endpoint = fmt.Sprintf("ceph://%s", endpoint)
	}
	uri, err := url.ParseRequestURI(endpoint)
	if err != nil {
		return nil, fmt.Errorf("Invalid endpoint %s: %s", endpoint, err)
	}
	name := uri.Host
	conn, err := rados.NewConnWithClusterAndUser(cluster, user)
	if err != nil {
		return nil, fmt.Errorf("Can't create connection to cluster %s for user %s: %s", cluster, user, err)
	}
	if opt := os.Getenv("CEPH_ADMIN_SOCKET"); opt != "none" {
		if opt == "" {
			opt = "$run_dir/jfs-$cluster-$name-$pid.asok"
		}
		if err = conn.SetConfigOption("admin_socket", opt); err != nil {
			logger.Warnf("Failed to set admin_socket to %s: %s", opt, err)
		}
	}
	if opt := os.Getenv("CEPH_LOG_FILE"); opt != "none" {
		if opt == "" {
			opt = "/var/log/ceph/jfs-$cluster-$name.log"
		}
		if err = conn.SetConfigOption("log_file", opt); err != nil {
			logger.Warnf("Failed to set log_file to %s: %s", opt, err)
		}
	}
	if err := conn.ReadDefaultConfigFile(); err != nil {

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Verify cluster and user names match your Ceph deployment (e.g. cluster "ceph", user "client.admin")
  2. Ensure librados is installed and compatible (build with ceph tag supported on your platform)
  3. Test connectivity with `ceph --cluster <cluster> --name <user> -s` before mounting
  4. Check CEPH_CONF environment variable points to a valid config

Example fix

// before
newCeph("mon1", "wrongcluster", "admin", "")
// after
newCeph("mon1", "ceph", "client.admin", "")
Defensive patterns

Strategy: validation

Validate before calling

// Shell: verify cluster/user before starting
ceph --cluster "$CEPH_CLUSTER" --name "$CEPH_USER" -s >/dev/null || {
  echo "cannot talk to cluster as $CEPH_USER"; exit 1;
}

Try / catch

// Go
obj, err := object.NewCeph(endpoint, cluster, user, "")
if err != nil && strings.Contains(err.Error(), "Can't create connection") {
    // check librados availability and cluster/user params
}

Prevention

When it happens

Trigger: rados.NewConnWithClusterAndUser returns an error — typically an invalid cluster name or user string, or the underlying librados failing to initialize for the given cluster/user pair.

Common situations: Wrong --ceph-cluster or --ceph-user values; user name typo (e.g. missing ".client" suffix conventions); librados not installed or version mismatch in the environment.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/292b299b5450f077. Report an issue: GitHub.