a year ago
MongooseError: The uri
parameter to openUri()
must be a string, got "undefined". Make sure the first parameter to mongoose.connect()
or mongoose.createConnection()
is a string.
I don't understand what the issue is. I used this before and this wasn't an issue previously. I put the Environment variables in correctly:
MONGO_URI=mongodb+srv://USERNAME:PASSWORD@super-projects.fasdsuee.mongodb.net/
Anybody know why it works on localhost, but I am getting this error when trying to host on the cloud?
20 Replies
a year ago
Hello Yes,
I gave an example of what is showing up in the railway variables I created in the question above. It is very similar excluding my actual user name and password. Also thanks for the quick response
a year ago
// connect to db
mongoose.connect(process.env.MONGO_URI)
.then(() => {
// listen for request
app.listen(port, () => {
console.log('Connected to DB and listening on PORT ' + port);
})
})
.catch((error) => {
console.log(error)
})
a year ago
not sure if a picture would be better
Attachments
a year ago
Please use code blocks when sending code.
Are you committing your .env file to GitHub?
a year ago
Sorry about the code brackets. didn't know how to do that in this forum.
I didn't commit the .env file. that is in my .gitignore file
a year ago
Code blocks here are done the same as any other forum.
Let's see your service variables.
a year ago
Here is screenshots of both:
Attachments
a year ago
No
a year ago
Well I'm out of ideas for now, maybe if you shared your repo something might stand out.
a year ago
Unfortunately I had to go to a different hosting provider and it worked without issues!
a year ago
Had the same issue kind of with my golang project. The only thing I can think of is I had a newer version of Go than what was allowed on the platform at the time. I know it sounds weird, but It seemed to work on older versions.
a year ago
FYI - I came back this morning and fixed the issue. it was so simple. LOL. railway had something on the left that told me they made changes and I need to update it. So I pressed it and when it updated the server was fine after that. No more error message. /cry
a year ago
Ah I should have caught that, my bad, I now see the blue unsaved changes in your screenshot.