apache/cassandra · error · MarshalException

Unable to make inet address from '%s'

Error message

Unable to make inet address from '%s'

What it means

InetAddressType.fromString() converts a textual IP address into its binary form using InetAddress.getByName(source); any failure (unresolvable hostname, malformed literal) is wrapped in this MarshalException. It means the string supplied is not a valid or resolvable IPv4/IPv6 address in the environment where it was parsed.

Source

Thrown at src/java/org/apache/cassandra/db/marshal/InetAddressType.java:70

    {
        return true;
    }

    public ByteBuffer fromString(String source) throws MarshalException
    {
        // Return an empty ByteBuffer for an empty string.
        if (source.isEmpty())
            return ByteBufferUtil.EMPTY_BYTE_BUFFER;

        InetAddress address;

        try
        {
            address = InetAddress.getByName(source);
        }
        catch (Exception e)
        {
            throw new MarshalException(String.format("Unable to make inet address from '%s'", source), e);
        }

        return decompose(address);
    }

    @Override
    public Term fromJSONObject(Object parsed) throws MarshalException
    {
        try
        {
            return new Constants.Value(InetAddressType.instance.fromString((String) parsed));
        }
        catch (ClassCastException exc)
        {
            throw new MarshalException(String.format(
                    "Expected a string representation of an inet value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed));
        }
    }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Validate the string is a well-formed IP literal before calling fromString
  2. Use explicit IP literals instead of hostnames to avoid DNS dependence
  3. Correct the malformed address in the config/data source
  4. Catch MarshalException and reject the record with the offending source string

Example fix

// before
ByteBuffer addr = InetAddressType.instance.fromString("192.168.1.1000"); // throws
// after
if (!isValidInetLiteral("192.168.1.1000")) throw new IllegalArgumentException("bad inet value");
ByteBuffer addr = InetAddressType.instance.fromString("192.168.1.100");
Defensive patterns

Strategy: validation

Validate before calling

try { InetAddress.getByName(source); } catch (Exception e) { throw new IllegalArgumentException("Invalid inet value: " + source); }

Type guard

static boolean isValidInet(String s) { try { InetAddress.getByName(s); return true; } catch (Exception e) { return false; } }

Try / catch

try { InetAddressType.instance.fromString(source); } catch (MarshalException e) { /* log source and cause; reject or substitute default */ }

Prevention

When it happens

Trigger: Calling InetAddressType.instance.fromString("not-an-ip") (directly or via fromJSONObject) where InetAddress.getByName throws UnknownHostException or similar; also hostnames that fail DNS resolution at parse time.

Common situations: Loading seed/host lists with typos ('127.0.0.1.' or '192.168.1'); inserting bad inet values via cqlsh JSON inserts; DNS outages making previously resolvable hostnames unresolvable; IPv6 literals missing brackets.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/889f92ad2112dda8. Report an issue: GitHub.