Private mongodb reference variable is not working
pavanbhaskardev
PROOP

9 months ago

[06:29:27] ERROR: Error: cannot connect to MongoDB. Details: getaddrinfo ENOTFOUND mongodb-pukz.railway.internal
    err: {
      "type": "p",
      "message": "getaddrinfo ENOTFOUND mongodb-pukz.railway.internal",
      "stack":
          MongooseServerSelectionError: getaddrinfo ENOTFOUND mongodb-pukz.railway.internal
              at $ (/app/.next/server/chunks/7525.js:231:62770)
              at T.openUri (/app/.next/server/chunks/7525.js:231:69912)
              at async Object.e4 [as connect] (/app/.next/server/chunks/7525.js:35:5573)
              at async t$.init (/app/.next/server/chunks/7525.js:189:16372)
              at async tN (/app/.next/server/chunks/7525.js:189:19626)
              at async /app/.next/server/chunks/3106.js:1:24645
      "reason": {
        "type": "Unknown",
        "servers": {
          "mongodb-pukz.railway.internal:27017": {
            "address": "mongodb-pukz.railway.internal:27017",
            "type": "Unknown",
            "hosts": [],
            "passives": [],
            "arbiters": [],
            "tags": {},
            "minWireVersion": 0,
            "maxWireVersion": 0,
            "roundTripTime": -1,
            "minRoundTripTime": 0,
            "lastUpdateTime": 6407291,
            "lastWriteDate": 0,
            "error": {},
            "topologyVersion": null,
            "setName": null,
            "setVersion": null,
            "electionId": null,
            "logicalSessionTimeoutMinutes": null,
            "maxMessageSizeBytes": null,
            "maxWriteBatchSize": null,
            "maxBsonObjectSize": null,
            "primary": null,
            "me": null,
            "$clusterTime": null,
            "iscryptd": false
          }
        },
        "stale": false,
        "compatible": true,
        "heartbeatFrequencyMS": 10000,
        "localThresholdMS": 15,
        "setName": null,
        "maxElectionId": null,
        "maxSetVersion": null,
        "commonWireVersion": 0,
        "logicalSessionTimeoutMinutes": null
      }
    }

I've a nextjs-app which getting deployed on railway via DockerFile, when i'm trying to add mongo ${{MongoDB.MONGO_URL}} it's failing, but it's working with ${{MongoDB.MONGO_PUBLIC_URL}}

Solved

5 Replies

david
EMPLOYEE

9 months ago

Please refer to Private Networking docs here: https://docs.railway.com/guides/private-networking

Would also check that the private URL is correctly set and the application is configured to resolve IPv6 addresses

Finally, would make sure all services are within the same project and environment.

Thanks,

David


Status changed to Awaiting User Response Railway 9 months ago


pavanbhaskardev
PROOP

8 months ago

Hi @david, during docker-image build if i try to connect railway internal variables then won't work right?


brody
EMPLOYEE

8 months ago

The private network is indeed not available during build.


pavanbhaskardev
PROOP

8 months ago

Thanks for confirmation, my-app is trying to connect to mongodb with internal-variable during docker-build

that's why it's failing!


akhil-naidu
PRO

8 months ago

@brody thanks for the confirmation, we can close this now.


Status changed to Solved chandrika 9 months ago


Loading...