If you're watching this, here's whats going on with the 502 error: Don't make a new variable in elastic beanstalk called "port"! Amazon already sets the environment variable for you...but they set the variable "PORT", not "port". So in your app.js code change "process.env.port" to "process.env.PORT" and things will work properly... Except they won't. For a lot of you, you're still getting a 502 error. But that isn't because of the port; your application simply can't start, with or without AWS. The issue is that AWS is trying to run a command like "npm start" but it isnt working. On your local machine navigate to the project directory in your terminal and try "npm start". If that fails, then you've found the problem. Here's how you fix it... npm start, by default, looks for a file called "server.js", not "app.js" like he told you to name your file. There are two solutions. The first is to change the settings in your project to make it look for "app.js" instead. The second solution is to simply change "app.js" file name to "server.js". I recommend the second option. Repush after making these changes and you should be good to go.
Caleb I know it's 2 years later but thanks for this video bro. You've always had down to earth explanations that people from all learning styles can understand.
I like that you showed even the errors you encountered so that it can help us debug/fix it. Thank you buddy! I will slap the "like" button and subscribe too!
For anyone watching and still getting a 502 error make sure to define a "start" script in your package.json, in my case I did: "start":"node app.js" Also make sure to define your port in env config and look in the logs to see which port your environment is running on
god bless you man, the problem was the json file. people, be careful even if the "start":"nodemon server.js" looks like this. it will BE WRONG because of nodemon, just use node server.js as well or app.js if thats the case
@@Heliotropeeee I wish I read the comments earlier, I just found it in the logs that nodemon was the issue. then I came to the comments and immediately saw this hahaha
Man just what I needed! Thanks! If any of you guys is having trouble trying to connect to a RDS Database from an Elastic Beanstalk Node.JS app check the SECURITY GROUP POLICY of the DB to accept traffic from Custom > Your Beanstalk Instance (this must be done manually) . Also check if you have a NPM RUN script in your package.json (it wont work otherwise) and your ENVIRONMENT VARIABLES set in the Beanstalk environment section.
instead of adding port as env variable you should use PORT(all caps) in your code for it to work also it is a good practice to have environment variables in all caps
Hey man thanks for this video, I used to watch you alot during my senior year of university for DBMS. Glad to see that 3 years later you're still producing content that is completely relevant to me haha
Bloomin eck Caleb - nicely done. I needed a very simple start for my first was deploy - I feel like I learned all the steps waaay beyond this and was missing this critical step. Subscribed. Thank you.
So good. Thank you. This worked great for me (had been trying to figure it out for a while). Site up and going , until it's time to hit the DB on Atlas! Would be great to see the Mongo DB part you were going to do.
haven't finished watching this but already loving it. Subscribed straight away. I am in the process of making a complete career re-direction aka "CHANGE" and will need easy-to-follow videos like this one here. Nice one Caleb!!
Love the video and your attitude! Keep it up! When you see the kind of videos AWS Solution Architects make you're happy that they're not the only ones.
Hi Caleb! Could you please help me with deployment my NodeJS application? I did everything according to your tutorial, but for some reason only the deploy to the AWS EB does not work
Cool Caleb. Tip for beginners, AWS EB considers app.js as default start script. If different, explicitly mention in package.json. "start": "src/app-main.js"
I have created a express app with around 10 api endpoints and hosted on elastic beanstalk server, how do I check how much compute resource each endpoint is taking?
I know this is later but im having this problem still with the 502 nginx error and the port fix doesnt work but im also using a Postgres db thats on RDS and i think that may be causing the issue as well. any suggestions?
you missed to create buildspec.yml , might be that's one failed to deploy To update your application to use Express On your local computer, create an .ebextensions directory in the top-level directory of your source bundle. In this example, we use node-express/.ebextensions. Add a configuration file that sets the Node Command to "npm start": node-express/.ebextensions/nodecommand.config option_settings: aws:elasticbeanstalk:container:nodejs: NodeCommand: "npm start"
well after a whole day of researching looks like the Proxy server: nginx doesn't recognize my process.env.port so i hardcoded to 8080 and it worked.... not the best practices but it's a start. For anyone following this tutorial, wich is very good BTW just change this line of code and i'll be fine. const port = process.env.port || 8080
Edit: Solution at the bottom of this comment Everything went perfect for me besides the part 2 deploy on the CodePipeline. This was my error: "Deployment completed, but with errors: During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version. " I did everything the same as the video (will review again) - any advice? EDIT: The error in the AWS logs (download by going to environment -> logs) was that my package.json file did not specify a node version. I added "engines":{"node":"12.18.3"}, to my package.json top-level (inside the first {}, right after "name": "project0",). Then I got an error in the logs saying that it couldn't get my dependencies... so then, in my .gitignore, I put a # (comment symbol) in front of the node_modules line under dependencies. Boom problem fixed. Now I'm just dealing with the 502 issue with the help of the comments Cheers
Hey man, I keep getting this error when I try deploy the pipeline, do you know what the issue could be? Action execution failed Deployment completed, but with errors: During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version. Failed to deploy application. Unsuccessful command execution on instance id(s) 'i-08cb1ec6aa6770914'. Aborting the operation. [Instance: i-08cb1ec6aa6770914] Command failed on instance. An unexpected error has occurred [ErrorCode: 0000000001].
For someone who is getting this error - the solution is you might have defined node version in your package.json file. Correct it or remove details of node version from your package.json file. Cheers...
it works but its not free, internally load balance is used with t2.small instance type which is not free and there is no way of stopping application, only termination of application is available. pls suggest some free instance
Thank you so much! btw some differences were there when running this in my case. By the help of the comment section I was able to deploy my app. Great Explanation 🤩❤️
Really cool man thanks for the tutorial, just what I needed. I had to open port "8080" in my settings, so guess they are distributed differently, maybe you should put that into the description if someone has the same issue (you find it in the log if anyone missed that).
thank God you finally did, I thought you would say "We couldn't make it in this tutorial, let me create another one and watch it next week" hah, anyways, Great stuff very helpful!
“we want to deploy node.js REST API on AWS. currently using elastic beanstalk service to deploy the api from github. But we want to enable "https" on our api. right now the url that aws gives is http only”
Thank You So.............................Much Sir. Finally, deploy my node application on AWS and it's working fine. One more time thanks and also subscribe to your channel.
Hi ..thank you for making this.. I tried this but my i was failed as my app has express module.. It is quite tough tutorials for express module app ..can you create a tutorial for that too..?
Great tutorial, thanks for putting this up. I'm not sure you need to put the picture in picture of you there though, just the monitor screen would be good, means we see more too eh - cheers.
hey caleb, thanks for this tutorial. i have a problem and was hoping you could help me. I'm extremely new to web dev, so this may be a silly question. but i used node js to build a website (basically a blog) that incorporates a load of images. my directory contains a public folder than contains my css stylings and images for the website. it loads just fine on my computer but i want to deploy it can i upload this folder with all the images, etc. directly to amazon and deploy it directly? or am i supposed to find a database to store my images and then link it up to my node js application somehow? thanks, any help would be much appreciated
I just released a Python version of this video! How to deploy a Python web app (AWS) for beginners - ua-cam.com/video/4tDjVFbi31o/v-deo.html Check out ClickUp! Replace all your apps for free! www.calcur.tech/clickup
perfect , it lookd very nice , please share the source code link for reference as well if possible , i have multiple aws lambda functions in a git repo , any help would be appreciated
If you're watching this, here's whats going on with the 502 error:
Don't make a new variable in elastic beanstalk called "port"! Amazon already sets the environment variable for you...but they set the variable "PORT", not "port". So in your app.js code change "process.env.port" to "process.env.PORT" and things will work properly...
Except they won't. For a lot of you, you're still getting a 502 error. But that isn't because of the port; your application simply can't start, with or without AWS. The issue is that AWS is trying to run a command like "npm start" but it isnt working. On your local machine navigate to the project directory in your terminal and try "npm start". If that fails, then you've found the problem. Here's how you fix it...
npm start, by default, looks for a file called "server.js", not "app.js" like he told you to name your file. There are two solutions. The first is to change the settings in your project to make it look for "app.js" instead. The second solution is to simply change "app.js" file name to "server.js". I recommend the second option.
Repush after making these changes and you should be good to go.
This 100% solved my issue with bad gateway. Thanks!
+1
@Pety im still getting the 502 error :( any other suggestions? Im getting both connections just fine, it just won't let me open up the web app
im also trying to return in an html page, not just a welcome message
@@garinnmorton9640 oh no! when you run "npm start" on your local machine, does it work?
Caleb I know it's 2 years later but thanks for this video bro. You've always had down to earth explanations that people from all learning styles can understand.
You, Sir, are a true hero. Not the hero we deserved, but the hero we needed.
Almost 3 years later, and this is the best tutorial i've ever seen. Thank you so much
I like that you showed even the errors you encountered so that it can help us debug/fix it. Thank you buddy! I will slap the "like" button and subscribe too!
For anyone watching and still getting a 502 error make sure to define a "start" script in your package.json, in my case I did:
"start":"node app.js"
Also make sure to define your port in env config and look in the logs to see which port your environment is running on
god bless you man, the problem was the json file.
people, be careful even if the "start":"nodemon server.js" looks like this.
it will BE WRONG because of nodemon, just use node server.js as well or app.js if thats the case
@@Heliotropeeee I wish I read the comments earlier, I just found it in the logs that nodemon was the issue. then I came to the comments and immediately saw this hahaha
>"502 Bad Gateway, yeah!... so that's the end of the tutorial."
hahahaha
I am halfway to the video, the way you summed up everything. its marvellous and big thank you
Man just what I needed! Thanks!
If any of you guys is having trouble trying to connect to a RDS Database from an Elastic Beanstalk Node.JS app check the SECURITY GROUP POLICY of the DB to accept traffic from Custom > Your Beanstalk Instance (this must be done manually) . Also check if you have a NPM RUN script in your package.json (it wont work otherwise) and your ENVIRONMENT VARIABLES set in the Beanstalk environment section.
FINALLYYYYY, a good tutorial on how to deploy with aws. THANK YOU!!!!
Thanks a lot Caleb!
Love how you celebrate your failures/errors. That's the best attitude
Yes caleb we are very interested on a tutorial on how to use mongo db with this. pls do
This was exactly what I needed to get my app up and running. Thank you for a down-to-earth, straightforward tutorial
instead of adding port as env variable you should use PORT(all caps) in your code for it to work also it is a good practice to have environment variables in all caps
Hey man thanks for this video, I used to watch you alot during my senior year of university for DBMS. Glad to see that 3 years later you're still producing content that is completely relevant to me haha
Bloomin eck Caleb - nicely done. I needed a very simple start for my first was deploy - I feel like I learned all the steps waaay beyond this and was missing this critical step. Subscribed. Thank you.
The best tutorial on deployment of node project on AWS! thanks
I had a local env with mongoDB/atlas but it was impossible to find a tutorial on how to bring everything live. Your tutorial nailed it thanks!
9:49 "Maybe it's not. I don't know. I don't know your life!" bro i died.
This video is gold.
So good. Thank you. This worked great for me (had been trying to figure it out for a while). Site up and going , until it's time to hit the DB on Atlas! Would be great to see the Mongo DB part you were going to do.
worked first time. great tutorial. keep up the great work. thank you
haven't finished watching this but already loving it. Subscribed straight away. I am in the process of making a complete career re-direction aka "CHANGE" and will need easy-to-follow videos like this one here. Nice one Caleb!!
Love the video and your attitude! Keep it up!
When you see the kind of videos AWS Solution Architects make you're happy that they're not the only ones.
Thank you from Brazil! You helped me a lot hehe
thank you , you just made my job 5X easier
Awesome video. How do I set up staging and development environment using ELB from different branches
Hi Caleb!
Could you please help me with deployment my NodeJS application?
I did everything according to your tutorial, but for some reason only the deploy to the AWS EB does not work
Cool Caleb. Tip for beginners, AWS EB considers app.js as default start script. If different, explicitly mention in package.json. "start": "src/app-main.js"
tutorial start at 10:36
Hey Caleb, How we can add the mongo db to that workflow?
Thank So So So So Sooooo Much Brother... Was Watching and Doing The work at 3:43AM ..And Yes It Worked Perfectly..!!! LIKED + SUBSCRIBED!!1
I have created a express app with around 10 api endpoints and hosted on elastic beanstalk server, how do I check how much compute resource each endpoint is taking?
This video was exactly what I was looking for. Your the best
You're the best, God bless.
20:04 an emotion felt by programmers universally
I know this is later but im having this problem still with the 502 nginx error and the port fix doesnt work but im also using a Postgres db thats on RDS and i think that may be causing the issue as well. any suggestions?
Preying is a very important part of the process 20:03
That deployment reaction is one we all know all too well! 😂😂
Outstanding! Cristal clear :)
Very informative video, I appreciate you showing us the trial and error and breaking down concepts. Thank you.
Beanstalk URL doesn't have HTTPS enabled 😭.
Is there a way to add SSL in the load balancer without custom domain ???
Happy teacher's day bro 😌😌
you missed to create buildspec.yml , might be that's one failed to deploy
To update your application to use Express
On your local computer, create an .ebextensions directory in the top-level directory of your source bundle. In this example, we use node-express/.ebextensions.
Add a configuration file that sets the Node Command to "npm start":
node-express/.ebextensions/nodecommand.config
option_settings:
aws:elasticbeanstalk:container:nodejs:
NodeCommand: "npm start"
I subscribed to the channel as soon as I finished the video! Awesome work Bro !
well after a whole day of researching looks like the Proxy server: nginx doesn't recognize my process.env.port so i hardcoded to 8080 and it worked.... not the best practices but it's a start.
For anyone following this tutorial, wich is very good BTW just change this line of code and i'll be fine.
const port = process.env.port || 8080
const port = process.env.PORT || 3000 change to PORT instead of port.
Thanks man.....after a day of searching this helped me....god bless you
we dont need a ec2 instance here?
Edit: Solution at the bottom of this comment
Everything went perfect for me besides the part 2 deploy on the CodePipeline. This was my error: "Deployment completed, but with errors: During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version. " I did everything the same as the video (will review again) - any advice?
EDIT: The error in the AWS logs (download by going to environment -> logs) was that my package.json file did not specify a node version. I added "engines":{"node":"12.18.3"}, to my package.json top-level (inside the first {}, right after "name": "project0",). Then I got an error in the logs saying that it couldn't get my dependencies... so then, in my .gitignore, I put a # (comment symbol) in front of the node_modules line under dependencies. Boom problem fixed. Now I'm just dealing with the 502 issue with the help of the comments
Cheers
Hey man, I keep getting this error when I try deploy the pipeline, do you know what the issue could be?
Action execution failed
Deployment completed, but with errors: During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version. Failed to deploy application. Unsuccessful command execution on instance id(s) 'i-08cb1ec6aa6770914'. Aborting the operation. [Instance: i-08cb1ec6aa6770914] Command failed on instance. An unexpected error has occurred [ErrorCode: 0000000001].
get the same issue. did you find way to solve it?
@@xiaoyuelyu8539 any news?
Can anyone help here. I am getting same error
For someone who is getting this error - the solution is you might have defined node version in your package.json file. Correct it or remove details of node version from your package.json file. Cheers...
All the checks passed, my code is the same, but the public url times out every time. Do you have any possible solutions?
Do we need to use docker or jenkins with elastic beanstalk?
For any gateway issues.
const port = process.env.PORT || 3000 use PORT instead of port
Thanks, man! That worked for me.
solve the problem Caleb, thank you very much.
100% helpful mate, Could you please revert the mongodb with aws video ulr please ?
Amazing video! I was so confused with all the different pieces just reading the docs 🥵
Your awesome dude! I already hit the subscribe button! Please do more Videos just like this one.
you might have to use port 8080. 8081 caused 502 bad gateway for me.
I’d be interested in the mongodb part
it works but its not free, internally load balance is used with t2.small instance type which is not free and there is no way of stopping application, only termination of application is available. pls suggest some free instance
i cant see the container options ,,please help?
nodejs deployment
Thank you so much! btw some differences were there when running this in my case. By the help of the comment section I was able to deploy my app. Great Explanation 🤩❤️
Really cool man thanks for the tutorial, just what I needed. I had to open port "8080" in my settings, so guess they are distributed differently, maybe you should put that into the description if someone has the same issue (you find it in the log if anyone missed that).
Yeah! A CRUD app would be great! THanks!
it's very useful but still get the error 502! no google answer :( .. What was ur problem share plz.
thank God you finally did, I thought you would say "We couldn't make it in this tutorial, let me create another one and watch it next week" hah, anyways, Great stuff very helpful!
Oh man, thank you very much!!!, now I don’t need any help from devops 😀
“we want to deploy node.js REST API on AWS. currently using elastic beanstalk service to deploy the api from github. But we want to enable "https" on our api. right now the url that aws gives is http only”
will beanstalk know which command to use to run the node server
You can type in order to open your current directory in VS Code directly.
Thank You So.............................Much Sir. Finally, deploy my node application on AWS and it's working fine. One more time thanks and also subscribe to your channel.
Thanks Caleb, you're awesome as always. Cheers
How to do it with a monorepo?
Thanks a lot for this man. I really needed it
Thank you!
Wow! great video👍
Great tutorial thanks! Just what I was looking for. Would love one that includes mongo too.
Brooooooo , it's a gemmmm !!!!!!!!!!!!!!! not only subbed, smashed that bell also !!!!!!!!!!!!!!!!!!!!!!!!!
Really helped so much. Please keep doing this great work.
thank you so much, I learned something new
Hi ..thank you for making this.. I tried this but my i was failed as my app has express module.. It is quite tough tutorials for express module app ..can you create a tutorial for that too..?
Nice video! I'll be waiting for the next vid about how to include mongo on this setup, thanks!
youre a life saver sir
how to make http to https in this deployment
You saved my day. Thank you so much !!
Great demo, provides value.
how to assign domain to this
Great tutorial. Exactly what I needed. Thanks!
Great tutorial, thanks for putting this up. I'm not sure you need to put the picture in picture of you there though, just the monitor screen would be good, means we see more too eh - cheers.
Do i install less.js first?
helped me - thanks! in my case - port=8080
Great tutorial thanks. It would be great if it is enhanced to using RDS DB and React front end.
This tutorial is amazing, thank you
Cool tutorial! Thanks man!
hey caleb, thanks for this tutorial.
i have a problem and was hoping you could help me. I'm extremely new to web dev, so this may be a silly question.
but i used node js to build a website (basically a blog) that incorporates a load of images.
my directory contains a public folder than contains my css stylings and images for the website.
it loads just fine on my computer but i want to deploy it
can i upload this folder with all the images, etc. directly to amazon and deploy it directly?
or am i supposed to find a database to store my images and then link it up to my node js application somehow?
thanks, any help would be much appreciated
There is a storage place in amazon. Amazon S3.
Very helpful! Thanks for sharing!!
Really good information !!
very helpful. thanks. plz do one with mongodb
I just released a Python version of this video! How to deploy a Python web app (AWS) for beginners - ua-cam.com/video/4tDjVFbi31o/v-deo.html
Check out ClickUp! Replace all your apps for free! www.calcur.tech/clickup
I click on your links in gratitude)
how come your and my elastic beanstalk menu is different zz
Love this videos
perfect , it lookd very nice , please share the source code link for reference as well if possible , i have multiple aws lambda functions in a git repo , any help would be appreciated