a month ago
2026-07-16T21:14:39.045Z INFO 1 --- [Chap-App-Backend] [ main] org.mongodb.driver.client : MongoClient with metadata {"driver": {"name": "mongo-java-driver|spring-boot|sync", "version": "5.8.0"}, "os": {"type": "Linux", "name": "Linux", "architecture": "amd64", "version": "6.18.15+deb13-cloud-amd64"}, "platform": "Java/Oracle Corporation/21.0.2+13-58"} created with settings MongoClientSettings{readPreference=primary, writeConcern=WriteConcern{w=null, wTimeout=null ms, journal=null}, retryWrites=true, retryReads=true, readConcern=ReadConcern{level=null}, credential=null, transportSettings=null, commandListeners=[], codecRegistry=ProvidersCodecRegistry{codecProviders=[ValueCodecProvider{}, BsonValueCodecProvider{}, DBRefCodecProvider{}, DBObjectCodecProvider{}, DocumentCodecProvider{}, CollectionCodecProvider{}, IterableCodecProvider{}, MapCodecProvider{}, GeoJsonCodecProvider{}, GridFSFileCodecProvider{}, Jsr310CodecProvider{}, JsonObjectCodecProvider{}, BsonCodecProvider{}, com.mongodb.client.model.mql.ExpressionCodecProvider@4cad79bc, com.mongodb.Jep395RecordCodecProvider@2c63762b, com.mongodb.KotlinCodecProvider@7a9eccc4, EnumCodecProvider{}]}, loggerSettings=LoggerSettings{maxDocumentLength=1000}, clusterSettings={hosts=[localhost:27017], srvServiceName=mongodb, mode=SINGLE, requiredClusterType=UNKNOWN, requiredReplicaSetName='null', serverSelector='null', clusterListeners='[]', serverSelectionTimeout='30000 ms', localThreshold='15 ms'}, socketSettings=SocketSettings{connectTimeoutMS=10000, readTimeoutMS=0, receiveBufferSize=0, proxySettings=ProxySettings{host=null, port=null, username=null, password=null}}, heartbeatSocketSettings=SocketSettings{connectTimeoutMS=10000, readTimeoutMS=10000, receiveBufferSize=0, proxySettings=ProxySettings{host=null, port=null, username=null, password=null}}, connectionPoolSettings=ConnectionPoolSettings{maxSize=100, minSize=0, maxWaitTimeMS=120000, maxConnectionLifeTimeMS=0, maxConnectionIdleTimeMS=0, maintenanceInitialDelayMS=0, maintenanceFrequencyMS=60000, connectionPoolListeners=[], maxConnecting=2}, serverSettings=ServerSettings{heartbeatFrequencyMS=10000, minHeartbeatFrequencyMS=500, serverMonitoringMode=AUTO, serverListeners='[]', serverMonitorListeners='[]'}, sslSettings=SslSettings{enabled=false, invalidHostNameAllowed=false, context=null}, applicationName='null', compressorList=[], uuidRepresentation=UNSPECIFIED, serverApi=null, autoEncryptionSettings=null, dnsClient=null, inetAddressResolver=null, contextProvider=null, timeoutMS=null}
2026-07-16T21:14:39.051Z INFO 1 --- [Chap-App-Backend] [localhost:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017
my application.properties is configured properly still the mongo db is connecting to localhost:27017
19 Replies
a month ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • about 1 month ago
a month ago
Why is it trying to connect to localhost? You sure you have used mongodb uri correctly?
mayori
Why is it trying to connect to localhost? You sure you have used mongodb uri correctly?
a month ago
yes i have checked it
a month ago
can u help me with this
a month ago
Mongo host should be something like *.railway.internal or *.proxy.rlwy.net , make sure you have a variable for mongo uri that reference to the private mongo url ${MongoDB.MONGO_URL}
sujalsrivastava
can u help me with this
a month ago
Can you share the snippet code that initializing the mongo connection? or if it's a public repo you can share the repo link here
a month ago
Just a double check, do you have MONGO_URL defined on your backend variables on railway?
a month ago
yes
a month ago
did you find anything
sujalsrivastava

a month ago
You haven't click deploy, it's on the top left on your screen
a month ago
it's not fixing
a month ago
can you try log the env MONGO_URL to make sure the env was injected to your app
a month ago
Did you find anything wrong with my application.properties
a month ago
Found the solution
You just have to change all spring.data.mongodb.* to spring.mongodb.* on your application.properties file
I added spring.mongodb.database to the properties because i got "Database must not empty" error while debugging
I also create a PR if you want to directly apply the changes from my test branch
