[ERRO] Bootstrap host `couchbase` does not have a valid DNS entry

UseCase;
Running the couchbase 7.2.0 build and registered along with consul
and I am able to see the couchbase service in consul dashboard service list. But still from spring-boot application not able to connect couchbase using “couchbase” host and fails while containerization deployment
----------configure.sh ---------------------------
#!/bin/bash

set -m

/entrypoint.sh couchbase-server &

track if setup is complete so we don’t try to setup again

FILE=/opt/couchbase/init/setupComplete.txt

if ! [ -f “$FILE” ]; then

used to automatically create the cluster based on environment variables

cluster-init | Couchbase Docs

echo $COUCHBASE_ADMINISTRATOR_USERNAME ":"  $COUCHBASE_ADMINISTRATOR_PASSWORD

sleep 15

# change couchbase => 172.20.0.3
curl -v -X POST http://couchbase:8091/pools/default -d memoryQuota=512 -d indexMemoryQuota=512

curl -v http://couchbase:8091/node/controller/setupServices -d services=kv%2cn1ql%2Cindex%2cfts

curl -v http://couchbase:8091/settings/web -d port=8091 -d username=$COUCHBASE_ADMINISTRATOR_USERNAME -d password=$COUCHBASE_ADMINISTRATOR_PASSWORD

curl -i -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://couchbase:8091/settings/indexes -d 'storageMode=memory_optimized'

sleep 2s 

    # used to auto create the bucket based on environment variables
    # https://docs.couchbase.com/server/current/cli/cbcli/couchbase-cli-bucket-create.html

    #/opt/couchbase/bin/couchbase-cli bucket-create -c couchbase:8091 \
    #--username $COUCHBASE_ADMINISTRATOR_USERNAME \
    #--password $COUCHBASE_ADMINISTRATOR_PASSWORD \
    #--bucket $COUCHBASE_BUCKET \
    #--bucket-ramsize $COUCHBASE_BUCKET_RAMSIZE \
    #--bucket-type couchbase

curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://couchbase:8091/pools/default/buckets -d name=$COUCHBASE_BUCKET -d bucketType=couchbase -d ramQuotaMB=128 -d authType=sasl -d saslPassword=$COUCHBASE_BUCKET_PASSWORD
sleep 2s
curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://couchbase:8091/pools/default/buckets/$COUCHBASE_BUCKET/scopes -d name=inventory
sleep 2s
/opt/couchbase/bin/couchbase-cli collection-manage -c couchbase \
    --username Administrator \
    --password password \
    --bucket $COUCHBASE_BUCKET \
    --create-collection inventory.fleet
sleep 2s
/opt/couchbase/bin/couchbase-cli collection-manage -c couchbase \
    --username Administrator \
    --password password \
    --bucket $COUCHBASE_BUCKET \
    --create-collection inventory.route
sleep 2s
/opt/couchbase/bin/couchbase-cli collection-manage -c couchbase \
    --username Administrator \
    --password password \
    --bucket $COUCHBASE_BUCKET \
    --create-collection inventory.cottage
sleep 2s
/opt/couchbase/bin/couchbase-cli collection-manage -c couchbase \
    --username Administrator \
    --password password \
    --bucket $COUCHBASE_BUCKET \
    --create-collection inventory.locations
#curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://couchbase:8091/pools/default/buckets/$COUCHBASE_BUCKET/scopes/inventory/collections -d name=cottage -d maxTTL=63113904 -d history=false
#curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://couchbase:8091/pools/default/buckets/$COUCHBASE_BUCKET/scopes/inventory/collections -d name=route -d maxTTL=63113904 -d history=false
#curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://couchbase:8091/pools/default/buckets/$COUCHBASE_BUCKET/scopes/inventory/collections -d name=fleet -d maxTTL=63113904 -d history=false
#curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://couchbase:8091/pools/default/buckets/$COUCHBASE_BUCKET/scopes/inventory/collections -d name=locations -d maxTTL=63113904 -d history=false
sleep 2s
curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://couchbase:8091/pools/default/buckets/$COUCHBASE_BUCKET/scopes -d name=tenant
sleep 2s
/opt/couchbase/bin/couchbase-cli collection-manage -c couchbase \
    --username Administrator \
    --password password \
    --bucket $COUCHBASE_BUCKET \
    --create-collection tenant.users
sleep 2s
/opt/couchbase/bin/couchbase-cli collection-manage -c couchbase \
    --username Administrator \
    --password password \
    --bucket $COUCHBASE_BUCKET \
    --create-collection tenant.bookings
sleep 2s
/opt/couchbase/bin/couchbase-cli collection-manage -c couchbase \
    --username Administrator \
    --password password \
    --bucket $COUCHBASE_BUCKET \
    --create-collection tenant.usersession
#curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://couchbase:8091/pools/default/buckets/$COUCHBASE_BUCKET/scopes/tenant/collections -d name=users -d maxTTL=63113904 -d history=false
#curl -v -u $COUCHBASE_ADMINISTRATOR_USERNAME:$COUCHBASE_ADMINISTRATOR_PASSWORD -X POST http://couchbase:8091/pools/default/buckets/$COUCHBASE_BUCKET/scopes/tenant/collections -d name=bookings -d maxTTL=63113904 -d history=false

#sleep 15
#curl -v http://couchbase:8091/query/service -d "statement=CREATE PRIMARY INDEX ON `$COUCHBASE_BUCKET`"

# create file so we know that the cluster is setup and don't run the setup again 
#touch $FILE


# Build the JSON payload for the service registration
SERVICE_PAYLOAD='{
"ID": "'$COUCHBASE_HOST'",
"Name": "'$COUCHBASE_HOST'",
"Address": "'$COUCHBASE_HOST'",
"Port": '$COUCHBASE_PORT',
"Check": {
    "HTTP": "http://'$COUCHBASE_ADMINISTRATOR_USERNAME':'$COUCHBASE_ADMINISTRATOR_PASSWORD'@'$COUCHBASE_HOST':'$COUCHBASE_PORT'/pools",
    "Interval": "10s"
    }
}'

# Send the PUT request to register the service with Consul
curl -X PUT -d "$SERVICE_PAYLOAD" http://consul:8500/v1/agent/service/register

fi

fg 1

----------register couchbase.sh in consul------------------
#!/bin/bash

Set the variables for Couchbase service registration

COUCHBASE_ID=“couchbase” # Unique identifier for the service
COUCHBASE_NAME=“couchbase” # Display name for the service
COUCHBASE_ADDRESS=“couchbase” # Service address (should match the container name in the Docker network)
COUCHBASE_PORT=8091 # Couchbase Web Console port

Build the JSON payload for the service registration

SERVICE_PAYLOAD=‘{
“ID”: "’$COUCHBASE_ID’",
“Name”: “‘$COUCHBASE_NAME’”,
“Address”: “‘$COUCHBASE_ADDRESS’”,
“Port”: ‘$COUCHBASE_PORT’,
“Check”: {
“HTTP”: “http://‘$COUCHBASE_ADDRESS’:‘$COUCHBASE_PORT’/pools”,
“Interval”: “10s”
}
}’

Send the PUT request to register the service with Consul

curl -X PUT -d “$SERVICE_PAYLOAD” http://consul:8500/v1/agent/service/register


./sdk-doctor-linux diagnose -u Administrator -p password couchbases://couchbase/homelab
|====================================================================|
| ___ ___ _ __ ___ ___ ___ _____ ___ ___ |
| / | | |/ /| \ / _ \ / | / _ | _ \ |
| _
\ |) | ’ <
| |) | () | (_ | || () | / |
| |
//||_\ |/ _/ _| |_| __/||\ |
| |
|====================================================================|

Note: Diagnostics can only provide accurate results when your cluster
is in a stable state. Active rebalancing and other cluster configuration
changes can cause the output of the doctor to be inconsistent or in the
worst cases, completely incorrect.

23:40:05.847 INFO :arrow_forward: Parsing connection string couchbases://couchbase/homelab
23:40:05.847 INFO :arrow_forward: Connection string was parsed as a potential DNS SRV record
23:40:05.898 INFO :arrow_forward: Connection string specifies to use secured connections
23:40:05.898 INFO :arrow_forward: Connection string identifies the following CCCP endpoints:
23:40:05.898 INFO :arrow_forward: 1. couchbase:11207
23:40:05.898 INFO :arrow_forward: Connection string identifies the following HTTP endpoints:
23:40:05.898 INFO :arrow_forward: 1. couchbase:18091
23:40:05.898 INFO :arrow_forward: Connection string specifies bucket homelab
23:40:05.898 WARN :arrow_forward: No certificate authority file specified (–tls-ca), skipping server certificate verification for this run.
23:40:05.917 WARN :arrow_forward: Your connection string specifies only a single host. You should consider adding additional static nodes from your cluster to this list to improve your applications fault-tolerance
23:40:05.917 INFO :arrow_forward: Performing DNS lookup for host couchbase
23:40:05.918 ERRO :arrow_forward: Bootstrap host couchbase does not have a valid DNS entry.
23:40:05.918 INFO :arrow_forward: Attempting to connect to cluster via CCCP
23:40:05.918 INFO :arrow_forward: Attempting to fetch config via cccp from couchbase:11207
23:40:05.920 ERRO :arrow_forward: Failed to fetch configuration via cccp from couchbase:11207 (error: dial tcp: lookup couchbase: Temporary failure in name resolution)
23:40:05.920 INFO :arrow_forward: Attempting to connect to cluster via HTTP (Terse)
23:40:05.920 INFO :arrow_forward: Attempting to fetch terse config via http from couchbase:18091
23:40:05.922 ERRO :arrow_forward: Failed to fetch terse configuration via http from couchbase:18091 (error: Get “http://couchbase:18091/pools/default/b/homelab”: dial tcp: lookup couchbase: Temporary failure in name resolution)
23:40:05.922 INFO :arrow_forward: Attempting to connect to cluster via HTTP (Full)
23:40:05.922 INFO :arrow_forward: Failed to connect via HTTP (Full), as it is not yet supported by the doctor
23:40:05.922 INFO :arrow_forward: Selected the following network type:
23:40:05.922 ERRO :arrow_forward: All endpoints specified by your connection string were unreachable, further cluster diagnostics are not possible
23:40:05.922 INFO :arrow_forward: Diagnostics completed

Summary:
[WARN] No certificate authority file specified (–tls-ca), skipping server certificate verification for this run.
[WARN] Your connection string specifies only a single host. You should consider adding additional static nodes from your cluster to this list to improve your applications fault-tolerance
[ERRO] Bootstrap host couchbase does not have a valid DNS entry.
[ERRO] Failed to fetch configuration via cccp from couchbase:11207 (error: dial tcp: lookup couchbase: Temporary failure in name resolution)
[ERRO] Failed to fetch terse configuration via http from couchbase:18091 (error: Get “http://couchbase:18091/pools/default/b/homelab”: dial tcp: lookup couchbase: Temporary failure in name resolution)
[ERRO] All endpoints specified by your connection string were unreachable, further cluster diagnostics are not possible

Found multiple issues, see listing above.

Indeed - “couchbase” will only work if your program is also running as a Docker container, and on the same Docker network as the Couchbase cluster. You don’t mention if your Spring Boot app is containerised, but SDK Doctor at least is not.

Two solutions - either run your Spring Boot app as a Docker container, per above. Or expose all the ports from the Couchbase cluster containers, and then just connect to them with the host’s name.

Put another way, here is how I run a single-node Couchbase cluster with Docker: “docker run -d --restart=always --name couchbase -p 8091-8095:8091-8095 -p 11210-11211:11210-11211 couchbase:7.2.1”

And now, because the ports are exposed, I can connect to it with just “couchbase://localhost:8091”.