- How to Deploy a Node.Js Application on AWS Lightsail
- What is Node.Js?
- What is AWS Lightsail and why use it?
- - What is an Instance?
- - Why use it?
- Deploying the Node.Js Application on AWS Lightsail
- - Step 1: Run Your Node.Js Project in IDE
- - Step 2: Create and Connect MySQL Database on Lightsail
- - Step 3: Create a new instance of the Node.Js application
- - Step 4: Connect the Instance through Filezilla
- - Step 5: Archive the Project on Local Machine
- - Step 6: Upload the project on the server
- - Step 7: Unzip the Folder and Run the Commands
- - Step 8: Access the Server IP Address
- - Step 9: To Keep the Server Running
- Conclusion
In this tutorial, we will teach you how you can deploy a nodejs application on Amazon Web Services (AWS) Lightsail. We will first explain these terminologies like node.js, and AWS Lightsail so let’s get started
Node.js is a server-side platform built on Google Chrome’s JavaScript Engine (V8 Engine). It’s is an open-source, cross-platform runtime environment for developing server-side and networking applications. Node.js applications are written in JavaScript and can be run within the Node.js runtime on Mac OS X, Microsoft Windows, and Linux.
Lightsail is an amazon web service for developers who need to build websites and web applications. You can choose an image for your Lightsail instance that jumpstarts your dev project so you don’t have to spend as much time installing software or frameworks.
Instances in AWS are virtual environments. It’s an on-demand service, which means a user can rent the virtual server(instances) that has all the operating systems and software installed and deploy their applications on it.
Lightsail has images with base operating systems, development stacks like LAMP, LEMP (Nginx), and SQL Server Express, and applications like WordPress, Drupal, and Magento.
It includes everything you need to launch your project quickly – instances (virtual private servers), container services, managed databases, content delivery network (CDN) distributions, load balancers, SSD-based block storage, static IP addresses, DNS management of registered domains, and resource snapshots (backups) – for a low, predictable monthly price.
The first thing you need to do is open your project or application in your preferred Integrated Development Environment(IDE). We are using WebStorm for this particular application.

Lightsail makes database administration more efficient by managing your common maintenance and security tasks. You can create your Mysql database by following the steps given here.
Once the database is created you need to connect and configure it. you can use any standard MySQL client application or utility to connect to it.You can connect your Mysql database by following the steps given here.
To set up your project you first need to login into the AWS account and go to the Lightsail dashboard and then perform the following steps.
Login and Create Instance
- Click on create an instance.
- Select a platform Linux/Unix.
- Select a blueprint Apps + OS (checked by default) Select: Node.js (14.16.1).
- Click Change SSH key pair Select existing key pair or create a new one.
- Choose your instance plan for example USD 4.5.
- Identify your instance (Your Lightsail resources must have unique names.) eg: firstnode_app.
- Click on Create instance button.
Connect and Configure the Instance
Once the instance is created you have to click on the terminal icon to connect instance and write the following command in the terminal.
cd stack

cd apps

Sudo mkdir myapp

sudo mkdir /opt/bitnami/apps/myapp/conf
sudo mkdir /opt/bitnami/apps/myapp/htdocs

sudo nano /opt/bitnami/apps/myapp/conf/httpd-prefix.conf
Add Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"

sudo nano /opt/bitnami/apps/myapp/conf/httpd-app.conf
Add ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/

sudo nano /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf
Include "/opt/bitnami/apps/myapp/conf/httpd-prefix.conf

FileZilla is a powerful and free software for transferring files over the Internet. It is a very popular FTP client and is used by webmasters from all over the world. Here you can download FileZilla software.
We need this to transfer our files between our local computer and Linux instance on Amazon Lightsail. For this, we will connect our instance using SFTP (SSH File Transfer Protocol).To do this, we need to get the private key for our instance, and then use it to configure the FTP client.
Download, Install and Get the Public IP Address :
Download and Install the Filezilla from the link given above. Now get the public IP address of your instance. Login into the Lightsail console, and then copy the public IP address that is displayed next to your instance, as shown in the image.

Get the SSH key for your instance
Follow these steps to get the default private key for the AWS Region of your instance, which is required to connect to your instance using FileZilla.
Note: If you’re using your key pair, or you created a key pair using the Lightsail console, locate your private key and use it to connect to your instance. Lightsail does not store your private key when you upload your key or create a key pair using the Lightsail console. You cannot connect to your instance using SFTP without your private key.
- Sign in to the Lightsail console.
- Choose Account on the top navigation bar, and then choose Account from the drop-down.
- Choose the SSH Keys tab.
- Choose Download next to the default private key for the region where your instance is located.

- Save your private key in a secured location on your local drive.
Configure FileZilla and connect to your instance
Complete the following steps to configure FileZilla to connect to your instance.
- Open FileZilla.
- Choose File, Site Manager.
- Choose New site, then give your site a name.

4. In the Protocol dropdown, choose SFTP – SSH File Transfer Protocol.
5. In the Host text box, enter or paste your instance’s public IP address.
6. In the Logon Type dropdown, choose Key File.
7. In the User text box, enter one of the following default user names depending on your instance operating system:
- Amazon Linux, Amazon Linux 2, FreeBSD, and OpenSUSE instances: ec2-user
- CentOS instances: centos
- Debian instances: admin
- Ubuntu instances: ubuntu
- “Certified by Bitnami” instances: bitnami
- Plesk instances: ubuntu
- cPanel & WHM instances: centos
Note: If you are using a different user name than the default user names listed here, then you might need to give the user write permissions to your instance.
8. Next to the Key File text box, choose Browse.
9. Locate the private key file that you downloaded from the Lightsail console earlier in this procedure, and then choose Open.

10. Choose Connect.
You may see a prompt similar to the following example, indicating that the host key is unknown. Choose OK to acknowledge the prompt and connect to your instance.
Now You are successfully connected if you see status messages similar to the following example:

Locate the folder of the node.js application you create on your local machine. Select the folder and compress it to create a zip executable file.
Now in step 3 when we were configuring the instance we had created a folder named “myapp”. To upload your project you need to log into the Lightsail console. Once logged in you need to select the terminal of the instance you created and go to the folder you created or in our case “myapp” and upload the zip folder there.
Once the folder is uploaded you needed to unzip the folder containing your project.
Now you need to run the following commands in the terminal.
This command will restart the scripts on your server.
sudo /opt/bitnami/ctlscript.sh restart apache
After restarting the scripts you need to run the following command to install the node module.
npm install
Once installed we will start our application on the server by running this command.
npm start
Now that everything is set up we will check if our application is successfully deployed or not.
For that, you need to copy the IP address of the instance you created shown on your Lightsail dashboard. Copy the IP address and paste it into the URL bar of the browser.
If it’s successful this will appear upon loading

Now that our application is deployed we need to make sure that the process keeps running by itself even when we have closed our local machine. To do that you need to run this command in the terminal.
Forever start bin/www
We have successfully deployed a Nodejs server on AWS using Lightsail service. We hope you find this article helpful. Feel free to contact us if you need any help regarding this topic. Do let us know the topics you want us to cover in the comment section or reach out to us with your queries by clicking the contact form below.
Good post. I’m experiencing a few of theseissues as well..
When I initially commented I clicked the “Notify me when new comments are added”checkbox and now each time a comment is added I get four e-mails with the samecomment. Is there any way you can remove me from that service?Many thanks!
Hi there, this weekend is fastidious in support of me,as this occasion i am reading this impressiveinformative piece of writing here at my home.
Thank you ever so for you blog.Thanks Again. Cool.
Why do copyright holders want to restrict distribution of their content to a particular country?
Aw, this was an incredibly nice post. Taking a few minutes and actual effort to produce a superb articleÖ but what can I sayÖ I put things off a whole lot and don’t manage to get anything done.
Thanks for your personal marvelous posting! I genuinely enjoyedreading it, you will be a great author. I will always bookmark yourblog and will often come back later in life. I wantto encourage one to continue your great job, have a nice weekend!
whoah this blog is fantastic i love reading your articles. Keep up the great work! You know, many people are searching around for this information, you can aid them greatly. Lyndy Ingrim Henden
Really appreciate you sharing this article.Thanks Again. Keep writing.
Fastidious answers in return of this issue with real arguments and describing all regarding that.
I really like and appreciate your blog.Really thank you! Awesome.
Looking forward to reading more. Great blog article.Thanks Again.
I quite like looking through a post that will make men and women think. Also, many thanks for permitting me to comment!
I just like the valuable info you provide on your articles.I will bookmark your blog and check once more here frequently.I’m somewhat certain I will be informed a lot of new stuff right here!Good luck for the following!
This piece of writing is truly a pleasant one itassists new internet viewers, who are wishing in favorof blogging.
Thank you for some other informative blog. Where else could I get that kind of info written in such an ideal method?I have a undertaking that I’m just now operating on, and I have been at the look out for such information.
I’ll right away grab your rss as I can’t to find your email subscription hyperlink or newsletter service. Do you’ve any? Kindly allow me understand so that I may subscribe. Thanks.
There’s definately a lot to learn about this issue. I love all ofthe points you have made.
There’s certainly a lot to learn about this issue.I love all of the points you have made.
Really appreciate you sharing this article post.Really thank you! Great.
I do trust all the ideas you’ve introduced on your post.They are very convincing and can certainly work. Nonetheless,the posts are too brief for novices. May you please extend them a bit from next time?Thank you for the post.
you will be able to play and that would end up being some
Thank you very much for sharing. Your article was very helpful for me to build a paper on gate.io. After reading your article, I think the idea is very good and the creative techniques are also very innovative. However, I have some different opinions, and I will continue to follow your reply.
I really like and appreciate your article. Really Great.
Hi, just wanted to mention, I enjoyed this article.It was practical. Keep on posting!
Hi there! I’m at work browsing your blog frommy new apple iphone! Just wanted to say I love reading your blog and look forward to all yourposts! Carry on the excellent work!Take a look at my blog :: Bye Bye Barks
Thank you for your shening. I am worried that I lack creative ideas. It is your enticle that makes me full of hope. Thank you. But, I have a question, can you help me? https://accounts.binance.com/en/register?ref=P9L9FQKY
lisinopril and magnesium hydrochlorothiazide rash
Really enjoyed this blog article.Really looking forward to read more. Keep writing.
Enjoyed every bit of your blog article.Really thank you!
It’s actually a nice and useful piece of info. I’m glad that you simply shared this helpful information with us. Please keep us up to date like this. Thanks for sharing.
Wow, great blog article.Thanks Again. Really Great.
online slot games online slot games slots games
I wanted to thank you for this great read!! I definitely loved every little bit of it. I’ve got you bookmarked to check out new things you postÖ
best canadian online pharmacy erectile dysfunction pills medicines for ed
1id2GV Si vous etes interesse, faites le pas et contactez un des mediums qui fait partie de notre centre d aastrologie et laissez-vous predire votre futur.
It is more of the mind reading as well as a decision-making strategy and just a little percentage of fortune.
The failure of equally standard method and card counting to identify
these minuscule sections is the reason for their disappointment.
Thanks so much for the post.Much thanks again. Much obliged.
There is certainly a great deal to find out about this subject.I like all of the points you have made.
Put to use Rolex during the world-wide industry is also extremely well known.
I may need your help. I’ve been doing research on gate io recently, and I’ve tried a lot of different things. Later, I read your article, and I think your way of writing has given me some innovative ideas, thank you very much.
glass dining tables will always be the best design and option that i would choose for our dining room”
An interesting discussion is definitely worth comment. I think that you need to publish more on this subject matter, it may not be a taboo subject but typically people don’t talk about such issues. To the next! Kind regards!!
Rattling informative and good complex body part of content material, now that’s user genial (:.
Hello friends, its wonderful article on the topic of educationand completely explained, keep it up all the time.
I truly appreciate this article post.Really thank you! Awesome.
I truly appreciate this blog post.Thanks Again.
Thank you for some other great article. Where else could anyone get that type of info in such a perfect way of writing? I’ve a presentation next week, and I am on the look for such info.
Very informative post.Really looking forward to read more. Really Great.
Aw, this was an exceptionally nice post. Spending some time and actual effort to produce a great article… but what can I say… I procrastinate a whole lot and never manage to get nearly anything done.
lisinopril and kidneys hydrochlorothiazide adverse effects
This is one awesome article post.Really looking forward to read more.
what causes erectile dysfunction – erectile dysfunction medication ed pills online malaysia
I’ll right away take hold of your rss feed as Ican not find your e-mail subscription hyperlink or e-newsletter service.Do you have any? Please let me understand in order that I may subscribe.Thanks.
Really appreciate you sharing this article post.Much thanks again. Great.
I every time spent my half an hour to read thisblog’s articles or reviews daily along with a cup of coffee.
I truly appreciate this article post.Really thank you! Want more.
A company car fame and fortune slots Next season, though, Appleyard played in just one match before breaking down completely
Fantastic article post.Really looking forward to read more. Will read on…
Aw, this was a very nice post. Spending some time and actual effort to make a superb articleÖ but what can I sayÖ I procrastinate a lot and never manage to get nearly anything done.