How to deploy my webpage created using NodeJS?

I have made some simple webpages on my computer that runs on localhost:3000.
Now I want to deploy these as a webpage that I can share with anyone as a link.
I tried Heroku but that did not work for me. I even tried tunneling my localhost using “ngrok”
but the link only works when the server is running on my system. Can someone help me out please?
here is the github link of my project- GitHub - kitarp29/Todolist: A to-do list web app built on NodeJS,MongoDB and Deployed using Heroku.Used this Project to Learn implementing Databases in web apps and deploy the web apps on online servers using MongoAtlas

If you have an router at your home try port farwarding to your global IP from the port 3000 . Then you can access your website from url
http://{global ip}:3000

1 Like

Deploying node app on Heroku can be achieved by creating a pipeline between GitHub and Heroku. Sure, you’ll have to set a few additional parameters that you can find here.

ngrok might not work due to shared IPs provided by ISPs. That’s why you cannot host websites on your local system anymore. Another way is to try deploying on a VPS, and if it works there, make those additional tweaks and deploy it on Heroku.

3 Likes

no I don’t have a router at home

I will try it out and will let you know.Thank you Bhaiya @rishabhlakhotia

2 Likes

Yeah, deploying on Heroku is easy. And if you want to run your server with command something like “node index.js” or “node server.js” then, you can either create a file named “Procfile” and paste “web: node index.js” or inside package.json add this:
“scripts”: {
“start”: “node server.js”,
},

3 Likes

thank you @Mohit_Agarwal Bhaiya creating the Procfile was the key. I finally was able to deploy it .Thanks!!.

1 Like