I am trying to deploy an authorization application to heroku. I cloned this repository and created a Procfile with the following line: web: node app.js. I manage to upload the application by git push heroku master but when I open it it says "Application Error". The same is with heroku local. I get "Express server listening on port 5000" and then an error "[MongoError: connect ECONNREFUSED 127.0.0.1:27017]
However, when I follow the repository instructions
In a separate shell start the MongoDB daemon.
mongod
From within the node-login directory, start the server.
node app
everything is fine and the app runs.
I would be so thankful for any help!
Unfortunately, in looking at that code repo it is hard coded to connect to a mongo instance running on your local machine. You can see that by opening the account-manager.js. This is why you get that error when pushing to heroku as when the app launches there is no mongo instance running on localhost.
When deploying to heroku, if you want to run mongo you will have to setup a mongo instance with one of their mongo add ons.
Once you do that, you will need to edit this codebase to connect to the mongo instance you signed up for (through addon) vs localhost. When you create an account with one of the providers you should be able to get a connection string and either use that directly in the code or use heroku's config vars.
Related
I have a backend node.js app setup in Heroku that uses a postgreSQL database. I have connected it to my github repo and can push my code to heroku fine it seems. I have installed the Heroku Postgres add-on, but for some reason I am unable to access the database using the heroku pg:psql command. When I run the command, it just states Connecting to databasename and no error or anything else pops up. Here are my gitbash commands:
olms2#LAPTOP-O3KD6RL5 MINGW64 ~/OneDrive/Desktop/Coding/Springboard/Current VS Code Projects/final-capstone-2-backend (master)
$ heroku addons
Add-on Plan Price State
ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ ΓöÇΓöÇΓöÇΓöÇΓöÇ ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
heroku-postgresql (postgresql-elliptical-01419) hobby-dev free created
ΓööΓöÇ as DATABASE
The table above shows add-ons and the attachments to the current app (freebay-backend) or other apps.
olms2#LAPTOP-O3KD6RL5 MINGW64 ~/OneDrive/Desktop/Coding/Springboard/Current VS Code Projects/final-capstone-2-backend (master)
$ heroku pg:psql
--> Connecting to postgresql-elliptical-01419
On a side note, I have no idea why the heroku addons command shows all that gibberish. I have tried deleting the entire app then reinstalling, but I still get the gibberish and unresponsive heroku pg:psql. I should mention that I created the app and installed the addon on the heroku website interface.
Seems there are a bunch of StackOverflow Answers referencing an error with the pg:psql command, but couldn't find any confronting an issue with the command not responding. Happy to provide more info and would really appreciate any help.
Please tell me the exact step by step instructions. Suppose I just newly cloned and built my new MEAN.JS application. It is running fine on my localhost.
And now I have created a new database at mlabs. Got the URI, user and passkey for that database from mlabs.
Now please tell me how to proceed to successfully deploy this application on heroku.
What I've tried : ---
I changed the production.js file, even the development.js file located in the env folder.
Ive done this in those two files. After doing this, when I run the app on my localhost, it successfully runs and the database gets connected to mLabs. But in heroku, it gives an application error. I am also including the heroku logs.
db: {
uri: "mongodb://xxx:mLabxxx#ds023624.mlab.com:23624/project",
options: {
user: 'username',
pass: 'password'
},
// Enable mongoose debug mode
debug: process.env.MONGODB_DEBUG || false
}
HEROKU LOGS
According to the logs, i think it is not able to connect to the database. See this error : --
[MongoError: connect ECONNREFUSED 127.0.0.1:27017]
Heroku runs your app on production environment as default, so you should check the production configuration.
Taking the repository you linked as a base, in this line it gets the DB url from environment variables called MONGOHQ_URL or MONGODB_URI, so you should either add them to Heroku with the MongoLab URI or replace on the code with the variable name you want (make sure it is created on Heroku too).
If it works on your localhost and not in Heroku, it means that the production config is wrong on Heroku, you should also make sure you are pushing the changes to the production config file to Heroku repository too. If you want to test on Heroku using the development environment, you can change this setting.
I have a mobile (Ionic 2) chat application with the following implementation, that uses nodejs-0.10 and MongoDB 3.2.7 and Meteor 1.4.1.1. It works perfectly on my localhost.
Now I need to deploy it to an OpenShift server. I have followed the following steps and created a server on OpenShift with Meteor. It is connecting with Git, and I can push my code to the server.
I am pretty sure the Meteor server is running on OpenShift, because I saw something to that effect on the startup logs (via ssh). However, I am not sure how to connect to the Meteor server to test it.
The domain is nodejs-easyjobs.rhcloud.com (54.208.77.250) on the OpenShift server, I can ping this successfully.
I am using Ionic 2 to build the mobile app. I am currently just running on Android, but plan to add iOS and Windows.
I am following this tutorial, and it runs on localhost. However, I am not sure where this is configured. I guess localhost is default, and you need to change it to a different host if needs be.
If I check my OpenShift server (nodejs-easyjobs.rhcloud.com) via ssh, I can see that the contents of the Meteor bundle directory is on the server. So Git is pushing the code.
The part I don't understand is:
Do I need to configure Meteor differently for being on the OpenShift
Server? Or do I just leave it as is?
Where do I configure the client
(Ionic 2) to point to the OpenShift server?
Question:
My question is, how do I configure my mobile app (Ionic 2) to connect to the OpenShift Meteor Server?
UPDATE:
My dir structure:
openshift-appname
.../ionic-apps/nodejs/bundle/server/...
meteorapp
.../ionic-aps/myIonicApp/api/.meteor/...
.../ionic-aps/myIonicApp/api/server/...
The contents of the .../ionic-apps/nodejs is cloned on the OpenShift server with Git.
I followed this tutorial to deploy the Meteor bundle to OpenShift. `
So I used the following to build my Meteor app:
> cd .../ionic-aps/myIonicApp/
> meteor build .../ionic-apps/nodejs --directory --server-only
As far as I can see, I may be wrong, but the Meteor Server is all correct and running on OpenShift. I need to know how I can get my Ionic2 app to access it.
Step1: Find the access point to the Meteor server using the OpenShift
IP. i.e. nodejs-easyjobs.rhcloud.com (54.208.77.250).
Step2: Configure my Ionic2 client to use this.
I built a Meteor app, and it runs on my local machine, where I have meteor installed.
I have never deployed an app online, and am trying to put the app on heroku.
I first tried to use buildpack/jordansissel/heroku-buildpack-meteor.git, but I got an error "Meteor requires Node v0.10.41 or later"
I then tried to use buildpack/michaltakac/meteor-buildpack-horse.git but it failed to push because it couldn't unpack Node.
Lastly I've tried kevinseguin/heroku-buildpack-meteor.git but I get lots of warnings about npm depricated http://prntscr.com/bewzak
When I look at the logs it says "Slug compilation failed: failed to compile Node.js app"
I also get Error: MONGO_URL must be set in environment
I don't know enough to understand what the errors are, or how to get my app deployed
Image of errors: http://prntscr.com/bex0av
my goal it to get the site on gr-fireworks.herokuapp.com
I contacted Heroku helpdesk and they said they couldn't help me because the issue was outside the scope of Heroku Support.
I tried to reach out to Snap CI who said they were successful in deploying it, but when I try to type in exactly what they did, I am still getting the error about Node https://snap-ci.com/ankitsri11/Fireworks/branch/master/logs/defaultPipeline/1/Heroku?back_to=build_history
My repository I'm trying to deloy is on git at github.com/jschwarzwalder/Fireworks
From description of your problem I can conclude you need to do 2 things on your app's Heroku dashboard (Settings tab):
Add MONGO_URL environment variable that points to your Mongo DB database. You can create mongo instance on external service or use mLab Heroku addon (it has free plan).
So your environment variables may look like:
Also, you may need to add METER_SETTINGS if you use --settings settings.json and ROOT_URL - URL of you app gr-fireworks.herokuapp.com (is required).
Set this buildpack:
Ensure you have .git at the end of url.
Now you can deploy your app using single command (if you setup Heroku Toolbelt and heroku remote points Heroku's app repository):
$ git push heroku master
I'm developing an app, using MEAN.js and its generator (https://github.com/DaftMonk/generator-angular-fullstack), and Openshift as a hosting.
The project template of the generator includes a script (server/config/seed.js) to populate the database with two users.
In localhost, it is called automatically, but I also can call it using node server/config/seed.js (suppose you're on the root app directory).
The problem is, when I deploy it to Openshift, I run it and no error is reported, but the mongodb database is not updated. The exactly steps I do to run it on Openshift are:
Connect to ssh: ssh ....
cd app-root/runtime/repo/
`node server/config/seed.js``
What am I missing?
Thanks in advance.
You have few options:
in server/config/production.js add
seedDB: true
or change NODE_ENV to development coz during 1st deployment it is set to production
then
grunt
grunt:buildcontrol:openshift
should be working now