I have deployed an application to heroku: https://stark-citadel-91743.herokuapp.com/
The app initially loads properly until you click a button that requires the database. Then it crashes.
Everything works in local development environment. I believe I have properly set up all connection settings for production in heroku dashboard's config variables (database url, database name, username, password). But in production it doesn't work.
Two evidences that it's not set up right:
1) When I log into the ClearDB MySQL plugin (in my heroku dashboard) under 'current connections' it says, 'No connections are currently established to the database.'
2) When I use postman to hit a custom endpoint I made just for testing a request to the database, I get: "Error adding color: Error: connect ECONNREFUSED 127.0.0.1:3306" <-- that 127.0.0.1 seems enlightening. Why would a deployed db have a connection on that address?
Any clues? Thank you!
If your database is also set up at keroku host:
check the db setting(username, pw, port,etc.)
If you actually need to connect back to your own database(which is hosted by you or other third party);
You should find out the setting and replace with 127.0.0.1:3306, which is only work for local env
Update:
127.0.0.1 is localhost, which is your machine. Your test case is working because your server and your database are hosting on the same machine(which both have same ip). However, when your code are deployed to heroku, your heroku server cannot find a database hosted on same machine. This is why your are having this problem
Related
I have this node.js accounts app that I'm trying to implement a mongoDB database onto, but it seems to have errors when I upload it to cpanel. My mongoDB url is in this format: mongodb+srv://:#. After some experimenting, turning the Node.js version to ^14 caused errors to stop, but the app still wouldn't run (going to the url reslted in a 503 error, this is the current state of the server).
github: https://github.com/codingtuba/accounts.aimedtuba/tree/mongodb
before mongo DB: https://github.com/codingtuba/accounts.aimedtuba
I am new in reactjs and nodejs.I made an application with react frontend and express backend. There are axios post and get requests for get data from mssql database via express.
When the project in production level, I write the IPv4 address and port for access dashboard from another device in local network. After build,when I use for example localhost:5000 for requests, I can see all datas which are come from database in the device which react project running but with this I cant see datas from android phone in local network.
What should I do? Isn't there any other way than writing a static IP address? This project can be run different machines.
I am sorry for my spelling mistakes.
I use zeit-now to deploy my website.
But I can't connect to my MySQL server.
I'm sure my MySQL server is able to be connected on my machine.
Here is my repo.
Any solution?
In the FAQ it says
Now itself focuses on being the best platform for serverless hosting. This means that the workloads we handle are static or stateless.
Still, you're trying to connect to your database on localhost. Although running a database instance in a docker container might be an option for a staging system, it definitely is not for production systems, since you will lose the data when you restart/redeploy. And you don't seem to startup a docker container in your deployment.
You should use a cloud database provider instead:
Use Cloud Databases that offer secure (preferably HTTPS-based) gateways, for example: Azure CosmosDB, MongoDB, Atlas, Firebase, Google Cloud SQL
I have a PhoneGap project on my windows 7 PC. I have installed the PhoneGap developer app on my PC which connects through server address: http://192.168.1.16:3000.
When I load the project on the PhoneGap developer app, everything works fine. The problem is that I have a database which is saved locally on my PC (localhost) and I access it through XAMPP. When I setup the XAMPP server I can not access the database and when I run the project it's showing me an error.
If I connect an online database on a server it works. I mean it's working with an online database but not working on localhost.
Can anyone help me how to access my database on localhost server.
var url = "http://localhost:81/myapp/auth.php";
And if i run open this link on above image result here:
enter image description here
Your app is running on the Phone and interprets localhost as its own host.
Try to use the IP you get from your Router of your PC smth. like 192.168.x.x or so.
Also be aware that direct connections to your PC-Database may be blocked because of the listen config of your MySQL Server
I have two applications - browser based client and NodeJS based server that are both communicating using WebSockets (I'm using ColyseusJS library). Problem is, that everything works fine while I'm testing them on localhost but when I deploy the application to my Ubuntu VPS server it stops working.
The message I receive in the browser while trying to connect is:
WebSocket connection to 'ws://X.X.X.X:8001/?colyseusid=' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET
So it reaches the server (because when server is disabled the message is "Error in connection establishment: net::ERR_CONNECTION_REFUSED") but it looks like it fails on Upgrade connection operation.
What is strange is that I managed to make it work yesterday (don't know how exactly), but had so much mess on my VPS that I decided to revert machine to it's starting state. After that it stopped working (code is unchanged). Maybe there are some additional dependencies that I need to install in order to make it work on my Ubuntu Server?
I would really appreciate your help.
Have you tried to port forward the port to the ip address of the said VPS in your router config? And also check out the firewalls.