# Mongoose can't be connected

**URL:** <https://forum.freecodecamp.org/t/mongoose-cant-be-connected/259793>\
**Category:** General\
**Created:** [February 18, 2019, 10:44pm UTC](https://forum.freecodecamp.org/t/mongoose-cant-be-connected/259793 "2019-02-18T22:44:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AliMohamed23](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/alimohamed23/32/108481_2.png) [@AliMohamed23](https://forum.freecodecamp.org/u/AliMohamed23)\
**Post date:** [February 18, 2019, 10:44pm UTC](https://forum.freecodecamp.org/t/mongoose-cant-be-connected/259793/1 "2019-02-18T22:44:13Z")

</div>

Hey Guys I am trying to pass this challenge  
but always give me the error

```auto
Mongoose is not connected

```

inspite of the rest two parts pass but this don’t that’s my code  
for myApp.js

```auto
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI);

```

for package.json:

```auto
	"name": "fcc-mongo-mongoose-challenges",
	"version": "0.0.1",
	"description": "A boilerplate project",
	"main": "server.js",
	"scripts": {
		"start": "node server.js"
	},
	"dependencies": {
		"express": "^4.12.4",
		"body-parser": "^1.15.2",
    "mongodb": "^3.1.13",
    "mongoose": "^5.4.13"
    
    
	},
	"engines": {
		"node": "4.4.5"
	},
	"repository": {
		"type": "git",
		"url": "https://hyperdev.com/#!/project/welcome-project"
	},
	"keywords": [
		"node",
		"hyperdev",
		"express"
	],
	"license": "MIT"
}

```

this is also my .env file

```auto
# Environment Config

# store your secrets and config variables in here
# only invited collaborators will be able to see your .env values

# reference these in your code with process.env.SECRET

SECRET=
MADE_WITH=
MONGO_URI=mongodb://xxxx:xxxx@ds027017.mlab.com:27017/BabyHadeer
# note: .env is a shell file so there can't be spaces around =

```

I have put into consideration not putting special characters in the URL  
ANY ONE HELP PLS

---

<div class="post-metadata">

**Author:** ![kevinSmith](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kevinsmith/32/72934_2.png) [@kevinSmith](https://forum.freecodecamp.org/u/kevinSmith)\
**Post date:** [February 18, 2019, 11:37pm UTC](https://forum.freecodecamp.org/t/mongoose-cant-be-connected/259793/2 "2019-02-18T23:37:11Z")

</div>

Can you try putting that mongo url string right in the _mongoose.connect_?

```auto
mongoose.connect('mongodb://xxxx:xxxx@ds027017.mlab.com:27017/BabyHadeer');

```

That would eliminate one problem area. If that doesn’t work, try to connect with mlab straight from mongo, or better yet Compass if you have it installed.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:04pm UTC](https://forum.freecodecamp.org/t/mongoose-cant-be-connected/259793/3 "2021-01-17T20:04:58Z")

</div>

Closed on January 17, 2021, 8:04pm UTC


