<!--
Before reporting a bug, please check for existing or closed issues
first …and read the instructions for filing a bug report:
https://github.com/meteor/meteor/blob/devel/CONTRIBUTING.md#reporting-a-bug-in-meteor
### This bug report should include:
- [ ] A short, but descriptive title. The title doesn't need "Meteor" in it.
- [ ] The version of Meteor showing the problem.
- [ ] The last version of Meteor where the problem did _not_ occur, if applicable.
- [ ] The operating system you're running Meteor on.
- [ ] The expected behavior.
- [ ] The actual behavior.
- [ ] A **simple** reproduction! (Must include the Github repository and steps to reproduce the issue on it.)
If you don't include a reproduction the issue is probably going to be closed.
### Independent packages
Please ensure your issue is opened in the appropriate repository:
* Feature Requests: https://github.com/meteor/meteor/discussions
* Blaze: https://github.com/meteor/blaze/
* Galaxy Guide: https://github.com/meteor/galaxy-docs/
-->
Meteor version: 2.7.1
OS: OSx Montery and Ubuntu (same result)
MongoDB version: 4.0.3
Expected behavior:
Meteor should not try to establish a connection to the local database if the MongoDB environment variables are set.
Actual behavior:
Meteor fails to start, because despite the MONGO_URL and MONGO_OPLOG_URL environment variables being set, meteor tries to establish a connection to 127.0.0.1:27017. This connection fails because the local database is not running, because the environment variables were passed.
An additional observation, the connection to the remote server is in fact established, as per MongoDB logs on the server:
```
2022-10-04T21:34:01.532+0000 I NETWORK [listener] connection accepted from xxx4:55118 #363 (2 connections now open)
2022-10-04T21:34:01.610+0000 I NETWORK [conn363] received client metadata from xxx:55118 conn363: { driver: { name: "nodejs", version: "4.3.1" }, os: { type: "Darwin", name: "darwin", architecture: "x64", version: "21.4.0" }, platform: "Node.js v14.19.1, LE (unified)|Node.js v14.19.1, LE (unified)" }
2022-10-04T21:34:01.672+0000 I NETWORK [conn363] end connection xxx:55118 (1 connection now open)
```
Meteor logs:
```
W20221004-17:34:31.359(-4)? (STDERR) /Users/xxx/.meteor/packages/meteor-tool/.2.7.1.1ebzwnf.mdfl++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:313
W20221004-17:34:31.406(-4)? (STDERR) throw(ex);
W20221004-17:34:31.406(-4)? (STDERR) ^
W20221004-17:34:31.406(-4)? (STDERR)
W20221004-17:34:31.407(-4)? (STDERR) MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
W20221004-17:34:31.407(-4)? (STDERR) at Timeout._onTimeout (/Users/xxx/.meteor/packages/npm-mongo/.4.3.1.udxozx.x3fz++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/sdam/topology.js:312:38)
W20221004-17:34:31.407(-4)? (STDERR) at listOnTimeout (internal/timers.js:557:17)
W20221004-17:34:31.407(-4)? (STDERR) at processTimers (internal/timers.js:500:7) {
W20221004-17:34:31.407(-4)? (STDERR) reason: TopologyDescription {
W20221004-17:34:31.407(-4)? (STDERR) type: 'ReplicaSetNoPrimary',
W20221004-17:34:31.409(-4)? (STDERR) servers: Map(1) {
W20221004-17:34:31.409(-4)? (STDERR) '127.0.0.1:27017' => ServerDescription {
W20221004-17:34:31.409(-4)? (STDERR) _hostAddress: HostAddress { isIPv6: false, host: '127.0.0.1', port: 27017 },
W20221004-17:34:31.409(-4)? (STDERR) address: '127.0.0.1:27017',
W20221004-17:34:31.409(-4)? (STDERR) type: 'Unknown',
W20221004-17:34:31.410(-4)? (STDERR) hosts: [],
W20221004-17:34:31.410(-4)? (STDERR) passives: [],
W20221004-17:34:31.410(-4)? (STDERR) arbiters: [],
W20221004-17:34:31.410(-4)? (STDERR) tags: {},
W20221004-17:34:31.410(-4)? (STDERR) minWireVersion: 0,
W20221004-17:34:31.410(-4)? (STDERR) maxWireVersion: 0,
W20221004-17:34:31.410(-4)? (STDERR) roundTripTime: -1,
W20221004-17:34:31.411(-4)? (STDERR) lastUpdateTime: 1920971665,
W20221004-17:34:31.411(-4)? (STDERR) lastWriteDate: 0,
W20221004-17:34:31.411(-4)? (STDERR) error: MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
W20221004-17:34:31.411(-4)? (STDERR) at connectionFailureError (/Users/xxx/.meteor/packages/npm-mongo/.4.3.1.udxozx.x3fz++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/cmap/connect.js:381:20)
W20221004-17:34:31.411(-4)? (STDERR) at TLSSocket.<anonymous> (/Users/xxx/.meteor/packages/npm-mongo/.4.3.1.udxozx.x3fz++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mongodb/lib/cmap/connect.js:301:22)
W20221004-17:34:31.411(-4)? (STDERR) at Object.onceWrapper (events.js:520:26)
W20221004-17:34:31.411(-4)? (STDERR) at TLSSocket.emit (events.js:400:28)
W20221004-17:34:31.411(-4)? (STDERR) at TLSSocket.emit (domain.js:475:12)
W20221004-17:34:31.411(-4)? (STDERR) at emitErrorNT (internal/streams/destroy.js:106:8)
W20221004-17:34:31.412(-4)? (STDERR) at emitErrorCloseNT (internal/streams/destroy.js:74:3)
W20221004-17:34:31.412(-4)? (STDERR) at processTicksAndRejections (internal/process/task_queues.js:82:21)
W20221004-17:34:31.412(-4)? (STDERR) }
W20221004-17:34:31.412(-4)? (STDERR) },
W20221004-17:34:31.412(-4)? (STDERR) stale: false,
W20221004-17:34:31.412(-4)? (STDERR) compatible: true,
W20221004-17:34:31.412(-4)? (STDERR) heartbeatFrequencyMS: 10000,
W20221004-17:34:31.412(-4)? (STDERR) localThresholdMS: 15,
W20221004-17:34:31.413(-4)? (STDERR) setName: 'rs0',
W20221004-17:34:31.413(-4)? (STDERR) maxSetVersion: 1,
W20221004-17:34:31.413(-4)? (STDERR) maxElectionId: ObjectId {
W20221004-17:34:31.413(-4)? (STDERR) [Symbol(id)]: Buffer(12) [Uint8Array] [
W20221004-17:34:31.413(-4)? (STDERR) 127, 255, 255, 255, 0,
W20221004-17:34:31.413(-4)? (STDERR) 0, 0, 0, 0, 0,
W20221004-17:34:31.413(-4)? (STDERR) 0, 2
W20221004-17:34:31.413(-4)? (STDERR) ]
W20221004-17:34:31.413(-4)? (STDERR) },
W20221004-17:34:31.413(-4)? (STDERR) commonWireVersion: 7,
W20221004-17:34:31.414(-4)? (STDERR) logicalSessionTimeoutMinutes: undefined
W20221004-17:34:31.414(-4)? (STDERR) }
W20221004-17:34:31.414(-4)? (STDERR) }
```
Steps to reproduce:
settings.json:
```
{
"packages": {
"mongo": {
"options": {
"tls": true,
"tlsCAFile": "ca.crt",
"tlsCertificateKeyFile": "cert.pem"
}
}
}
}
```
Start meteor:
```
export MONGO_URL='mongodb://xxx:xxx@xxx:27017/xxx?tls=true&tlsAllowInvalidHostnames=true'
export MONGO_OPLOG_URL='mongodb://xxx:xxx@xxx:27017/local?authSource=admin&replicaSet=rs0&tls=true&tlsAllowInvalidHostnames=true'
meteor run --settings ./settings.json
```
Am I missing something simple here? Very confused as to why it's still trying to connect to localhost. The database can be connected to without issue from a GUI client and command line. This issue happens on my local machine and when I try to deploy using meteor up.