title: How to deploy MERN stack to a hosting service?
body: <p>I am new to web development and I have a hosting service on which I want to deploy my reactjs/node project. To deploy it previously, I had been simply uploading the build folder created from running <code>npm run build</code>. I have since added a connection to a mongodb database using the MERN stack. </p>
  
  <p>The project was initially created using create-react-app, then I set up my backend node/mongodb following this tutorial: <a href="https://appdividend.com/2018/11/11/react-crud-example-mern-stack-tutorial/" rel="noreferrer">https://appdividend.com/2018/11/11/react-crud-example-mern-stack-tutorial/</a>. All of my server code is contained within the project folder in an api folder.</p>
  
  <p>I am able to run the project on local host by running <code>npm start</code>, <code>nodemon server.js</code> (from the api folder) and connecting to the mongodb in terminal. When I try to run it from the hosting service in the same way I did previously, it says it cannot connect to the database, which I assume is due to the fact that the connection is not open on my machine.</p>
  
  <p>Currently, all the API calls are using axios post to <a href="http://localhost:4000/" rel="noreferrer">http://localhost:4000/</a>, which I would also assume will not work on the server. I have looked online for information regarding deploying the MERN stack, but all of the ones I have found discuss it in terms of hosting on AWS EC2, which is not what I will be doing. </p>
  
  <p>How would I be able to deploy to my hosting service? 
  Are there any references or places I should look for this information?</p>
  
  <p>Edit: I have connected to the database using MongoAtlas, so am using a SRV address. I think the issue is the axios posts using the localhost address, as the app on the server only works if I have nodemon running on my local machine. What address should I use instead of this?</p>