---
title: "Comment by Fiona Nataprawira on \"Deploying MERN to Heroku (success)\" | Hashnode"
description: "Hello! I deployed my MERN app to Heroku, it is rendering properly and my third-party API search function works well. However, it seems like my GET and POST meth"
url: "https://hashnode.com/posts/deploying-mern-to-heroku-success/5737b4e8911fe184eb43bbb3/comment/58f521cb07c49a70fb299500"
---

[Discussion](https://hashnode.com/posts/deploying-mern-to-heroku-success/5737b4e8911fe184eb43bbb3)

Comment [Deploying MERN to Heroku (success)](https://hashnode.com/posts/deploying-mern-to-heroku-success/5737b4e8911fe184eb43bbb3)

[Fiona Nataprawira](https://hashnode.com/@nfiona)

[Apr 17, 2017](https://hashnode.com/posts/deploying-mern-to-heroku-success/5737b4e8911fe184eb43bbb3/comment/58f521cb07c49a70fb299500)

Hello!

I deployed my MERN app to Heroku, it is rendering properly and my third-party API search function works well. However, it seems like my GET and POST methods to add new data is not working now. I also lost the datas that were originally stored on my database. I got the below errors:

`GET [localhost/api/projects](https://localhost:3001/api/projects) net::ERR_CONNECTION_REFUSED     OPTIONS [localhost/api/projects](https://localhost:3001/api/projects) net::ERR_CONNECTION_REFUSED     Uncaught (in promise) Error: Network Error       at createError (createError.js:15)       at XMLHttpRequest.handleError (xhr.js:87)`

Originally I had the Mixed-Content error and I fixed that by adding the below to my index.html's head section: `<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">`

Here is link to my app: [https://fierce-sierra-67905.herokuapp.com/](https://fierce-sierra-67905.herokuapp.com/)

This is my first time deploying MERN app on Heroku and have struggled for a while. Any help would be much appreciated!

[Jake Foraker](https://hashnode.com/@jakeforaker)

[Apr 17, 2017](https://hashnode.com/posts/deploying-mern-to-heroku-success/5737b4e8911fe184eb43bbb3/comment/58f521cb07c49a70fb299500#reply-58f53a0a977c5336c6f48f29)

Looks like you forgot to update your own API url from your local development version. Make sure to change it to your new heroku URL. (Or omit the location and use just "/api/projects" if that makes sense for your configuration)

[Fiona Nataprawira](https://hashnode.com/@nfiona)

[Apr 17, 2017](https://hashnode.com/posts/deploying-mern-to-heroku-success/5737b4e8911fe184eb43bbb3/comment/58f521cb07c49a70fb299500#reply-58f540c1977c5336c6f48f2d)

Thank you [Jake Foraker](https://hashnode.com/@jakeforaker "'s Profile - Hashnode") ! That took care of the GET error, however my original datas are still not showing and I am still getting this:

```
POST fierce-sierra-67905.herokuapp.com 404 (Not Found)
```

My connection.js:

```
var mongoose = require("mongoose")
mongoose.connect("mongodb://localhost/projectbook", (err) => {
   if(err) {     
    console.log(err)  
 } else {     
console.log("MongoDB is Connected!")   } })

module.exports = mongoose
```

Package.json:

```
...

"scripts": {     
"start": "cross-env NODE_ENV=production MONGO_URL=mongodb://localhost/projectbook node index.js",     
"start-dev": "nf start -p 3000",     
"build": "react-scripts build",     
"test": "react-scripts/test.js --env=jsdom",     
"eject": "react-scripts eject"   },  
... 
"testEnvironment": "node",     
"testURL": "localhost", 
...
```

Am I supposed to deploy my mongodb on a separate heroku deployment?

Please pardon my ignorance, Thanks again for your help!

[Jake Foraker](https://hashnode.com/@jakeforaker)

[Apr 18, 2017](https://hashnode.com/posts/deploying-mern-to-heroku-success/5737b4e8911fe184eb43bbb3/comment/58f521cb07c49a70fb299500#reply-58f56de327471d3cc62907d5)

So it looks like you are trying to point to `localhost` again. You need a hosted instance of your database, with a connection string (url) that is accessible to the outside world (the interwebs). Luckily, Heroku makes this extremely easy with the mLab addon [elements.heroku.com/addons/mongolab.](https://elements.heroku.com/addons/mongolab.) All you have to do is add it, and you get a free tier instance.

You will replace your current `MONGO_URL` env variable with the new one provided by Heroku.
