Cluster Url connection not happening from rails server

I am using Rails 6, Ruby 2.7.3 along with
mongo (2.17.1)
mongo_auto_increment (0.1.3)
mongoid (7.0.13)
mongoid-compatibility (0.6.0)

cluster version - 6.0.5

I have setup cluster on mongo cloud but when our rails server trying to connect to mongo cluster we are getting issue, passing url like this to our application

MONGO_URL = mongodb+srv://username:password@xxxx-xxx-xx-xxxx.ru8xg.mongodb.net/db_name?retryWrite=true&w=majority

Error: ArgumentError: Host should not contain protocol. Did you mean to not use an array?"

Can anyone please guide how to fix this issue

This error is coming from the client validating an array of addresses and one contains what it thinks is the protocol. Can you share the actual connection string (without the username/passowrd) you’re using?

Thanks @alexbevi for your reply
I am using below url string only which i am passing to rails application using environment variable MONGO_URL

mongodb+srv://username:password@yabx-mtn-zm-zedfin.ru84g.mongodb.net/?retryWrites=true&w=majority

Same string i got from cluster config

@Anand_Kumar_Tripathi the issue doesn’t appear to be with your connection string - at least not directly:

[1] pry(main)> require 'bundler/inline'
=> true
[2] pry(main)> gemfile do
[2] pry(main)*   gem "mongo", "2.17.1"
[2] pry(main)* end
=> ""
[3] pry(main)> Mongo::Client.new('mongodb+srv://username:password@yabx-mtn-zm-zedfin.ru84g.mongodb.net/?retryWrites=true&w=majority')

=> #<Mongo::Client:0x1900 cluster=#<Cluster topology=ReplicaSetWithPrimary[yabx-mtn-zm-zedfin-shard-00-00.ru84g.mongodb.net:27017,yabx-mtn-zm-zedfin-shard-00-01.ru84g.mongodb.net:27017,yabx-mtn-zm-zedfin-shard-00-02.ru84g.mongodb.net:27017,name=atlas-quqaof-shard-0,v=1,e=7fffffff0000000000000002] servers=[#<Server address=yabx-mtn-zm-zedfin-shard-00-00.ru84g.mongodb.net:27017 SECONDARY replica_set=atlas-quqaof-shard-0 pool=#<ConnectionPool size=0 (0-5) used=0 avail=0 pending=0>>,#<Server address=yabx-mtn-zm-zedfin-shard-00-01.ru84g.mongodb.net:27017 SECONDARY replica_set=atlas-quqaof-shard-0 pool=#<ConnectionPool size=0 (0-5) used=0 avail=0 pending=0>>,#<Server address=yabx-mtn-zm-zedfin-shard-00-02.ru84g.mongodb.net:27017 PRIMARY replica_set=atlas-quqaof-shard-0 pool=#<ConnectionPool size=0 (0-5) used=0 avail=0 pending=0>>]>>

Note that the driver here is able to parse the connection string, parse the host list (from the SRV) record and create a topology (replica set with 3 members). If you can create a self-contained reproduction using mongoid that you could share that demonstrates the issue I’d be happy to review further.