joewalnes/websocketd · error

--socketmode %q is not an octal permission mode (e.g. 0700)

Error message

--socketmode %q is not an octal permission mode (e.g. 0700)

What it means

parseSocketMode validates the --socketmode flag value. The value must be a valid octal number; if strconv.ParseUint(s, 8, 32) fails, this error is returned so the operator knows the mode string is malformed.

Source

Thrown at config.go:90

	for _, o := range allowOrigins {
		if !strings.Contains(o, "://") {
			out = append(out, o)
		}
	}
	return out
}

// parseSocketMode parses the --socketmode flag: an octal permission mode
// such as "0700". The empty string means "not set" and leaves the socket
// file to the process umask; an explicit zero is rejected because it would
// make the socket unusable for everyone, owner included.
func parseSocketMode(s string) (os.FileMode, error) {
	if s == "" {
		return 0, nil
	}
	mode, err := strconv.ParseUint(s, 8, 32)
	if err != nil {
		return 0, fmt.Errorf("--socketmode %q is not an octal permission mode (e.g. 0700)", s)
	}
	if mode > 0o777 {
		return 0, fmt.Errorf("--socketmode %q has bits beyond permission bits (keep it within 0777)", s)
	}
	if mode == 0 {
		return 0, fmt.Errorf("--socketmode 0 would make the socket unusable; pick a mode like 0700")
	}
	return os.FileMode(mode), nil
}

// resolveAddresses builds the list of TCP addresses to listen on.
func resolveAddresses(addrlist []string, port int) []string {
	if len(addrlist) > 0 {
		addrs := make([]string, len(addrlist))
		for i, addr := range addrlist {
			addrs[i] = fmt.Sprintf("%s:%d", addr, port)
		}
		return addrs

View on GitHub (pinned to 7a8683dc7f)

Solutions

  1. Pass a pure octal string, e.g. --socketmode 0700 or 600
  2. Remove non-octal characters (8, 9, letters, quotes-in-shell artifacts)
  3. Quote the value in the shell if it starts with 0 to avoid weird expansion

Example fix

// before
websocketd --socketmode=rw --port=8080 ./script.sh
// after
websocketd --socketmode=0600 --port=8080 ./script.sh
Defensive patterns

Strategy: validation

Validate before calling

const isOctal = (s) => /^[0-7]+$/.test(s) && parseInt(s, 8) <= 0o777;
if (socketMode && !isOctal(socketMode)) throw new Error(`--socketmode ${socketMode} is not octal`);

Type guard

const isOctalMode = (s) => typeof s === 'string' && /^[0-7]+$/.test(s);

Try / catch

try { mode := parseSocketMode(flagValue) } catch { /* fall back to default 0700 and log */ }

Prevention

When it happens

Trigger: Running websocketd with --socketmode set to a string that is not a valid octal number, e.g. --socketmode=rwx or --socketmode=08 (8 is not an octal digit) or --socketmode=-1.

Common situations: Passing symbolic permissions like 'u=rwx' instead of numeric octal; copying a mode with a stray character or whitespace; assuming decimal input works.

Related errors


AI-assisted analysis of joewalnes/websocketd@7a8683dc7f (2026-09-03). Data as JSON: /api/errors/5b68388e9a0e2d1d. Report an issue: GitHub.