Deploy Node.js website on Heroku for Free
HTML-код
- Опубликовано: 28 сен 2024
- Today we are going to explore how to deploy a Nodejs website on Heroku for free. The project has to be non-commercial, but you can always upgrade to the paid plan if your project is business-focused.
Code: raddy.dev/blog...
☕ BuyMeACoffee: www.buymeacoff...
0:45 Introduction:
2:57 Node.js Project Setup:
2:57 Node.js Heroku Settings:
4:28 Creating Heroku App:
4:51 Uploading Node.js project to Heroku
8:37 Ending
Discounts:
⚡ Hostinger: www.hostg.xyz/...
⚡ Elementor: be.elementor.c...
Recording Equipment:
◾ Microphone: amzn.to/3Ppp8Ok
◾ Shotgun Mic: amzn.to/3IVqIot
◾ Camera: amzn.to/3z0bxpF
◾ Lens: amzn.to/3Pw4s7d
◾ Lighting: amzn.to/3PGXvzW
Computer Gear:
◾ Keyboard: amzn.to/3PGXvzW
◾ Headphones: amzn.to/3PJl9fg
◾ Mouse: amzn.to/3z1TGPf
Connect with me:
◾ Website: www.raddy.dev
◾ Newsletter: www.raddy.co.u...
#nodejs #heroku
What would you like to see next?
What is in the .env file ??
@@anishjoshi1999 that shouldn't be there haha. It was an API key for the NewsApi website
Explain MVC?
Angular production proxy config or solution for cros origin problems
cloning some web apps in react and node/express.
You look like real Madrid forward benzema😂😂😂😂😂😂😂😂😂...btw helpful vid👍👍
😂😂😂😂😂😂😂
for the past like 2 weeks I've been struggling only this Heroku staff couldn't find any answer and today was my last day as after today if it doesn't work I'm quitting but I don't know how I came to this video and the magic happened thanks, man, really thank you so much
Thanks.. This was really helpful for me. I deployed my application in 10 min right after watching this.
Also need to mention that for the free version, in memory data will be erased if there is no in coming traffic for a particular time. (May be 30 min)
Good point. Glad that you found the video useful! Thanks for the comment
Ephemeral file system. Resets every 24 hours with traffic and with no traffic every 30 minutes.
Nice content, well done. However, you missed all the security implementation in expressjs and how to deploy as production and having an environment for testing. Will be nice to have this. On Heroku do we need to add DB on heroku plan? What about azure
Thank you. Yeah, there is tons more that can be covered. I guess once you get started you can always refer to the documentation.
You can use their database functionality even on the free hobby plan if this is what you were asking.
Azure is another beast, so it's Google cloud, AWS and so on... Plenty of options 🙂
Hi Raddy, next you could do a tutorial on how to deploy a node.js with MySQL database on Heroku! Thanks for all the cool videos.
Hey Cesare, thank you for the comment and I like the suggestion. I will add it to my list
is it just me or the audio and video are not synced?
You are right, the audio is out of sync. No idea why that would have happened as I would have noticed when I was editing the video
In the Procfile you would have to use the actual name of your server file.
I like the simplicity of your explanations, just subscribed :)
Thank you, CoderLady! I appreciate you subscribing
Thank you very much. Finally I deployed my website after week of suffering.
No pain, no gain 💪
I got an error when trying to open the app. I got this " Error: Cannot find module 'express' when I checked with heroku logs. What happened?
You need to add express as dependency to your project. Heroku install them via npm install so you need to have it listed in your package.json
@@RaddyDev I've fix it already. Thanks a lot!
man i liked your style and setup
Thank you, I appreciate it!
Nice and straight forward thanks
If I want to make my API key as the privacy to .env file. So what should I make change on the get method newsAPI =? of news.js file?
You need to require dot env somewhere at the top of your app.js:
require('dotenv').config()
In your .env file you can add something like:
APP_KEY = your API key
And to use the variable in your application you would do something like:
process.env.API_KEY
I hope this helps
Maybe do an explanation on how to connect a domain to your heroku app so itt's ready to go live.
That's a good idea. I will do that, thank you
what about database ? can i use database in heroku ?
You can do. I believe that they have quite a few options
thank you mate, helped me a lot
Thank you .This video realy helps me
This is pretty confusing with the instructions not matching what's on the video... Still appreciate the explanation, though. 👍
I appreciate your comment. Unfortunately the instructions do change. I might have to update the article on my blog
After adding git add. So many statements come it's end less why is that so?
What do they say? Usually they are quite informative. Look at what the errors are and just look online how to solve them
Thank you very much!!!
It's really useful and clear to follow your steps.
Glad to hear that. Thank you for the comment!
What to do if I have MySQL database connection with my node js project
Instead of localhost you could remote connect to it and it should still work
@@RaddyDevok thanks man
YOU GOT A NEW SUB. KEEP IT UP MAN
I appreciate it, Blue!
Is it really free? One week after I deploy a sample app to Heroku, I suddenly got an email saying I got a charge - $1.23 for Application dynos. I don't remember what application dynos is.
Heroku is no longer free. If you started on the free tier, they would have warned you that your instance will stop working. They won't just randomly start charging you (I don't think). You've signed up to their paid tier by the sound of it. Cyclic and Render have free plans that you could try
If your package.json is not in the root directory. It cannot do this.
Thanks for the comment, Moroso! 🙂
Thanks !!!!!
great video man, you've earned a sub! Keep it up
Thanks for the sub!
Hi Raddy!
Thank you for your tutorial, working perfectly! I have one question for you. Is it possible to do, that on heroku save the upload file permamently? Because I have a nodejs website, where I have an image upload page, heroku save the image, but after a few hours, i see only blank images.
Hey, I am glad that it worked. I just had a look and you are right.
"Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad, but no files that are written are visible to processes in any other dyno and any files written will be discarded the moment the dyno is stopped or restarted."
You might have to use Cloud Storage. Companies such as Google, Amazon& IBM offer cloud storage. There might be something cheap or even free out there. I've only used Heroku for basic websites and I didn't realise that they reset the files.
@@RaddyDev thank you for your answer! i will try to fix it with cloud storage, if not working, then I need to deploy on a paid server. Sure, for basic website is a very good alternative to try your website on server for free! :)
Would I need to create a new repository and just move the code over from the old one to make this work, or can I do it with an already existing repo
Already existing repo is fine
Do you still need a Procfile in 2022? 🤔
Nope. The setup now is fairly straightforward
Can I deploy web socket project in heroku?
Deployed successfully but it is showing Application error "An error occurred in the application and your page could not be served.
Check to see if you are using process.env.PORT instead of hand-coding it
@@RaddyDev i am using first one and pipe sign then 3000 port number
This looks just like your problem: github.com/StartBootstrap/startbootstrap-freelancer/issues/89
Hopefully the answer on there will help
@@RaddyDev i got that
I putted a white space after web in Procfile, now i removed it and it worked👍
Hi Raddy,
Thanks for sharing, it will be helpful.
Unfortunately, the "local" and remote (heroku) versions do not work. I am indeed not getting any record on the "/" route
In "local" I get "no posts found" but no error on console.
On the "heroku" version, I get an error on the heroku console of the project:
"Error connect ECONNREFUSED 94.136.40.82:443"
I don't know what to do.
Thanks for your help
Alain
Hi Alain, thanks for the comment. I know what the problem is. A few days ago I changed my domain name and hosting IP address. Unfortunately I had a few issues with my domain and I couldn't do a re-direct on the same day. The redirect should work now and you won't get the error. Alternatively you can try raddy.dev. Saying this I do have some firewall protection in place which could also block access. It has happened once.
Hopefully it will just work now, but I will make a note for other people
@@RaddyDev Thank you. I've already tried the raddy.dev link without success as far as I remember. I'll try again later and let you know
Okay let me know. It might be my firewall... You can try pretty much any WordPress website that has their rest API open
Thanks
Heroku free dyno will no longer available on November 28 sad/
That's a shame... we need to find a good alternative
What's that file with .env extension. I'm having an application error
.env holds environment variables. In this example, we are storing our database host, user, and password. You can store all sorts of stuff in there. I actually just done a full tutorial on .env if you want to check it out. It's one of the last videos that I've done
Thank you so much!
Glad it helped!
Thank you !! amazing
reach 96% and didn't complete
why is that ?
You have to check the error logs in Heroku and they will tell you. It might give you an error code that you can google
i am getting a h10 error for get and post requests and my website has been crashed can you please help me out with this
It could be a number of things. Have a look at this article by Lawrence Eagles: dev [dot] to/lawrence_eagles/causes-of-heroku-h10-app-crashed-error-and-how-to-solve-them-3jnl
@@RaddyDev thanks pal
Bro, your pic hide all the command
Yep... mistakes were made there... I don't record my head now :-D
It will not work after 30 minutes inactive status
You mean that the app goes to sleep after 30 min of inactivity? That's pretty normal and I guess it's a good thing in terms of saving resources.
You can ping your website every 15 min or so if you like and that won't happen. Or get some visitors on your website :)
Thanks, it was a great tutorial. But you missed one thing to install git. I was not having git and it created some problem.
It really didn't cross my mind... thanks for letting me know, I will have to put a note on the video
wait is heroku like github ?
It's a little bit different. You can pretty much deploy projects in most languages and also manage data services. You can pick any database and get it installed fairly easy.
I am not sure if you could run a node js project on github... I think that you can only have static web pages?
you're a lifesaver
👊😎
Whats your vs code template? looks clean
Hi Otoniel, it's called Dracula 🧛♂️
@@RaddyDev Nice I just installed it and its fire. thanks!
Merci. T'es un mec bien
Merci beaucoup
Thank you sir
Thanks!!!
thank you very much
I hope that it was helpful. Thank you 👊😎
Thank U
You're welcome!
thank you soo much sir...........
Thank you, Jatil!
what the hell is in your .env this shit is not working for me
What error do you get? You can follow the new instructions on Heroku if this still doesn't work. I think that there are 4 fairly simple steps
@@RaddyDev hi, I finally made it by connecting my github repository, I'm sorry for the bad words, yesterday I was very upset :/
Super :)
Thank you!
merci bro
merci beaucoup
cannot GET /
Create a router. You probably haven't got one
Did you manage to finish the error because I'm facing the same thing
You probably haven't got that route created in your application
love from nepal
Thank you 👊🦍
KACHIGGA
calm down pls, you talk too fast :(
oh sorry i had two time speed on xDD my bad
@@chickhicks0 shut up NO he is talking too slow!!
oh i had zero point five speed on LOL
@@Naruto-lw9xf ????
merci
Thank you for watching
START reactjs
:)
Copy & Paste BENZEMA 😂
I have to get a Real Madrid t-shirt 😂
Cool - just a reminder that if you should add node modules f(and any other files that aren't used in the final build) to the git ignore file. That way all that stuff won't be uploaded.
Thanks bro
👊😎
Thanks, I missed the Procfile!
There was a way to make it work without the Procfile. If it works, don't fix it :-D
Thank's for the tutorial, still working in 2022 :)
That's always good to hear
Can anyone please help me!!!
I'm not able to use the git command in my vs code.
It's showing that 'git' command cannot is not recognized.
Try installing Git if you havent
@@RaddyDev Thanks.
Worked!!!!!
@@shauryaagarwal4689 that's awesome!
i try do like your tutorial. But when i open app with heroku, on page show this message: Upgrade Required. Tell me what's it and how to fix! my project is websocket server.
I am not sure what it could be. Did you not find anything on the web?
How to update npm on heruko ? Had deployed a project. But shows npm have a major update. Update to 8.... Vers. So how can i do ? Did i want to edit in project through git ? Or any other way ?
If you want to update your npm packages I would first test locally and then reupload. You can probably do it with the CLI, but I haven't tested it. It might be the case of doing npm update
you are best....love from India
it is not free anymore :
error: failed to push some refs to....
You probably haven't committed. git commit -m 'message'
Heroku guy 👍👍👍👍
does the site all you to host website for free with a domain name and hosting ?
Try Render as I don't think that this is free anymore
Struggling to install cli for Mac on Command line, help?
First, you have to get Homebrew which is a package manager for macOS & Linux. Go their page brew.sh and install it. They have one command installation. Once you do this, try Heroku CLI again. I hope that this works!
HUNDREDS OF THOUSANDS OF LIKES! Thanks
I appreciate you!
what if the running file is in a subfolder
in your package.json file, you can specify the subfolder and it should be fine
Great video !
Btw what are the limitations for the free plan ?
The free plan is for non-commercial apps, such as proof of concepts, MVP's, and personal projects
why is it soo easy
I made it look easy 😎 lol
im always getting port not binding error!!! pls help anybody .. i have tried literally everything but none are working!
Heroku automatically assigns the port number. So what you have to do is this:
.listen(process.env.PORT || 5000)
@@RaddyDev I've tried that too... It isn't working 😶
@@Pranauv In the logs can you see an error code? Usually you can google that and hopefully find the answer. I am not sure what else it could be
@@RaddyDev ok thanks
Cheers Mate!
Thank you for watching!
Thank you
Thank you for watching!
Thanks :)
Thank you for watching!
hey! I'm having links on my web pages that when clicked open a new ejs web page. It work totally fine in local server.But when hosted on heroku it give error that is Application error and unable to open the ejs page when click on the links
Hey, Aastha! It sounds like it could be the path to your files. It's obviously finding the pages locally, but for some reason not on heroku. You could set a static folder to be used if you haven't done that. Anyway, double check your path
thanks for your help, dude!
galit ka po ba
?
Holy shit! You are a legend! This finally worked for me after trying to troubleshoot an error for an hour and half. Thanks!
Glad that you found it helpful, Kintsugi. Thank you for watching!
Short and easy to follow. Thanks!
Thank you for watching!
Thank you so much
Thank You for taking the time to produce this video, this was helpful.
Oh, and get a haircut you, hippie!
Best
😂😂
Is it secure ? I have sensible information in my node js files
As far as I know it's secure. Heroku is pretty big
@@RaddyDev how can I update my git ?
@@darktools186 on windows you can do "git update" or "git update-git-for-windows" and on Linux you can do "sudo apt-get update" and then "sudo apt-get install git". I am not so sure about mac os. Also I do want to mention that storing sensitive information in your nodejs files might not be a good idea. Maybe use .env or some of the paid services. Just be careful that's all. Don't publish your nodejs project on github with all of the sensitive information that you are talking about. Other than that Heroku is a pretty well known service and in general people really like it. Shame that they are closing down their free tier...
@@RaddyDev thank you bro. Amazing video btw
wowo wowowo i can't express myself, i am trying from yesterday but i didn't find a tutorial like this!!!!!
Glad that you like the video. Thanks for the comment!
Thank you! 👏
Thank you for watching! High five 🖐😎
@@RaddyDev 🖐️😎
Pretty simple. I am Grateful
Dude u solved my 6hrs long problem in just 8 mins and 39 secs
Thank You so muchhh!!!!!!
Glad to hear that the video was helpful!
Thank you for kind video! I am heroku deploy-possible person now! :-)
I love it! Thanks for the comment, Juan
Thank you man! Subscribe done
Thanks for the support, brother! 👊🦍
thank you so muchh, you save my day!!!!
Any time, Diyah!
How can I solve error in heroku cannot GET/
Create a router for the page. Make sure that your project is working locally first and then you can upload
@@RaddyDev it's working locally. Like everything is well i even refactoring my code. Like to put the GET / route nut it's still the same
That's really strange. You could check in the Heroku logs to see if there are any errors. Is your project public on GitHub? It could be something small
@@RaddyDev I found the error it's refusing to send my react file when on heroku but in local dev it's working perfectly. This the error I get ..Error: ENOENT: no such file or directory, stat '/build/index.html'
@@libertydaniel6366 So I wound assume that you just need to build your project and then upload. Glad that you spotted that
Spot on explanation
Glad you liked it