My localhost works but the heroku database doesn't - node.js

I'm using the remote database URL on my laptop and it works perfectly on localhost. When I upload to heroku, it won't save new users to the database. It's still connecting to the database to start the web application (I think). I see the 'session' storage increasing by one every time I visit the website online. And I can definitely create new users and do everything it's supposed to on my laptop.
I've tried changing versions of the database from mongodb 2.6 to 3.0. I've tried switching out versions of mongoose so that they're compatible with the version of mongodb (http://mongoosejs.com/docs/compatibility.html).
I've tried deleting node_modules and doing a fresh npm install.
Been debugging this for months and have probably put over 100 hours in to it with no solution. Can someone please help? I have no idea why the database would work on this machine but not the heroku server. All I've figured out so far is that the reason it's not working is the database won't create documents from heroku.

Related

PERN stack deploying to Railway

Hi I've just finished a PERN project that I want to deploying using Railway, should be very easy according the people on the internet.
But I'm just so lost even to begin, I tried connecting to my Github, and I run into a an error already.
Then I wanted to try deploy my local postgres db first, so I set up the postgres db on railway, got the config pages and change my local postgres config to match railway...and then I'm lost
I tried searching on Youtuber and google, but it seems most people are either migrating from heroku, using django, or just not really showing how to deploy from beginning to end.
So I'm here looking for help to see if anyone could guide me to the right place (article or video) that actually shows or teaches how to deploy PERN stack to railway from step 1, which is after finishing the project locally.
A bit more info about the stack I'm using...
react 18
express.js
postgresql 14
node 16
BTW, I don't know if this is way I run into the first issue with Nixpacks, but I have my client (react) folder and server (express + postgres db) folder inside a project folder.
Thank you all so much, I appreciate all the help.

How to connect Mongo database to node in MacOs

I was uploading material for a website on mongo by node previously on my windows pc. Now, I don't have much idea about the technicality of it but all I used to do was open postman, open cmd, type "node index.js", cmd would show "connected to port 3000" and when I used to upload them through postman I could see the changes in Mongo.
Now that I have switched to mac, I don't have much idea how to go about this. I installed mongo, node, and npm using homebrew but I don't know how to set up a local connection between node and mongo to upload to the database.
Any help would be appreciated. Thank you.
ok...I am actually building a APP with MERN stack on Mongodb.
A mac is not much different...sorry a mac is way different-
Postman doesn't work well with mac at all-
Infact I can't even find anything to test a backend with on a mac using Postman from their own official page.
I found this helpful for testing an app with Postman-
https://tech-cookbook.com/2020/04/27/how-to-use-postman-on-mac-os-catalina-get-request-rest-api-example/
It's hard to find sources on Google because it has become a capitalist pig for corporations to sell on....I feel you.
When I started looking for help, I ran into more buy this product than actual tech help.
You can also pull from github repositories...because mac's provide additional security for the users, it's almost guaranteed 20 additional steps in development than a windows.

Developing locally using express, mongodb and mongoose

I'm currently making an app using express, mongodb and mongoose, and I'm running it locally on my machine. My problem is that if I'm not connected to the internet the app won't run at all due to the app not being able to connect to mongodb server.
I thought that if I ran the mongodb server locally on my computer along with the app then I wouldn't need an internet connection, or is my understanding wrong?
Any help would be much appreciated.
The answer is: yes.
If you install MongoDB locally then you won't need internet connection to access it.
Make sure that your connection string contains "localhost".
Also, make sure that you don't need anything else on the internet, and that you run npm install while you are connected to the internet, or otherwise your dependencies (like mongoose) won't get installed. After they are installed they can work without the internet connection just fine - if your database is on localhost.
Also, make sure that your local MongoDB server is running. You can run:
mongo test
in the command line to see if you can connect to a local database.
You're in the right path !
Here's the thing, you need to get yourself a copy of MongoDB, you can download and install the suitable version to your system from here.
Now you need to configure MongoDB in your in your path so you can launch it when you is or simply add it a process that will launch when your system starts.
In order to configure please choose the suitable conf to your system :
Windows.
Linux.
macOS.
Then, before running your application, make sure MongoDB is running in the background ad service or daemon and then simply launch your application.

Dreamweaver Database connection to phpmyadmin not working

So, I realise there are a lot of threads with this topic already but I have went through every single one of them (Majority of them are the exact same) and nothing seems to work.
**As a note, I am using a trial version of Dreamweaver cc 2015, and I am using WAMPSever.
So, I have a testing server working. The problem I am having is creating a MySQL connection from Dreamweaver to phpmyadmin. The error that persists is the:
HTTP ERROR CODE 404 File not found. Here are some possible reasons for the problem:
1) There is no testing server running on the server machine.
2) The testing server specified for this site does not map to the. Verify that the URL in the prefix maps to the root of the site.
I have moved the MMHTTPDB.php and mysql.php into the right folder. I have also selected the server model to be PHPMYSQL.
This is my site:
This is the testing server:
I am fairly new to using Dreamweaver but I have not been more frustrated with anything in my entire life.
Any help would be much appreciated.
I was in a similar situation a week ago and spent sleepless nights trying to find a solution. Like you, I have never been frustrated as I was by this. Finally, I had to downgrade my XAMPP version because I learnt that if you're using the deprecated server behaviors in Dreamweaver, they won't work with the latest version of XAMPP.
I downloaded an older version and I am okay now.

MongoDB accessible through localhost but not 127.0.0.1

I am trying to run a web application locally that uses grunt and mongodb. The app allows users to upload information which they can then view in their gallery.
started mongodb with mongod --port 3000 --httpinterface
(As mentioned in the comments, I have tried running it without the --httpinterface as well)
browsing to 127.0.0.1:3000 gives a page with only the text "It looks like you are trying to access MongoDB over HTTP on the native driver port."
browsing to localhost:3000 loads my application
the application sends data over 127.0.0.1, and it is not going through
It seems very relevant to what is going on in this question.
I hope this will not be considered a duplicate, because after finding that question I tried to work through the answers offered without success. If I was able I would have tried pursuing this issue in the comments there.
Following the answers on that question I tried running mongo with a config file without success (no config file existed beforehand, I tried to create one with the sample offered on the mongo website but it rejects it). I also tried deleting the lock files and repairing mongo. Nothing has changed.
It's probably worth mentioning that the application I'm working with is an existing, sparsely documented project that was given to me for a school assignment. It is far more complicated than anything I have ever worked on and I am very unfamiliar with tools like mongo.

Resources