Deploy & Run a Node.js Web Application on App Engine Last Updated : 08 Jan, 2024 Comments Improve Suggest changes Like Article Like Report Google Cloud Platform is one of the cloud service providers that provide various cloud services for a seamless experience. It provides various services like storage, networks, development tools, Analytics tools, infrastructure, and many more. To learn more about GCP you can follow this article Terminologies App Engine: This is a platform as a service of GCP that provides a fully managed serverless platform for application deployment.NodeJS: NodeJS is a runtime javascript environment. It executes JavaScript code outside the browser.How to deploy a web application on GCP? We are going to use a simple NodeJS application that shows "Hello World" as a response. Below is an example of an app.js file. JavaScript const express = require('express'); const app = express(); const port = 8000; app.get('/',(req,res)=>{ res.send("Hello World From GFG"); }) app.listen(port,()=>{ console.log("Server Started On "+port); }) You must install Express using npm. All the required dependencies must be installed. You can install Express using the below command inside the same folder as the app.js file.npm install expressWe are not deploying in production so we are not using environment variables here . If you want to deploy as production build then make sure you are using GCP secret manager and using proper environment variables.Lets test the application in local enviroment . For starting the server we will add custom start script in package.json file . Add following lines to package.json file . The file should look like this . The start script will start the server by executing app.js file . Node { "dependencies": { "express": "^4.18.2" }, "scripts": { "start": "node app.js" } } Run below command to start the server locally . npm startYou should see below output in terminal . Go to browser and hit 127.0.0.1:8000 . If you see "Hello World From GFG" then great the application is setup correctly we can deploy it.Now for deploying firstly download and install google cloud sdk on your machine . After successful installation you can verify by running "gcloud version" command.Google App Engine uses app.yaml file for configuring app engine instance so lets create app.yaml in folder where app.js file is located. Insert following code in app.yaml file. runtime : nodejs18Now initialize gcloud CLI if not already initialized by below command.gcloud initselect your project after logging in or create a new one.Now create a new app in app engine using below command . select region for application creation. This will create a new app in specified region.gcloud app createRun below command where app.yaml file is located which will deploy our NodeJS application .gcloud app deployReview details press Y to continue . After successful deployment you will see below output . Now to go to browser and go to service url of application OR run below command .gcloud app browse This will open browser with app URL. If you see "Hello World From GFG" then congratulations your app is deployed successfully. Troubleshooting A Deployed Web Application On GCPIf you get '502 Bad Gateway' error go to logs explorer to view what is wrong .If there is any other error check your project for configurations and make necessary changes.If you still cannot access the page check the firewall rules to check if there is blocking rule to the network which is blocking the traffic.If you are getting 404 Not Found then check the routes that you are accessing . Check that the route you are accessing exist in the server.Conclusion From this article we have learnt about deployment of NodeJS web applications on google cloud platform. We have also seen step by step process to deploy an web application. Comment More infoAdvertise with us Next Article Deploy & Run a Node.js Web Application on App Engine D deepcodr Follow Improve Article Tags : Node.js Similar Reads How to Deploy a Web Application on GCP? Google Cloud Platform is one of the cloud service providers that provide various cloud services for a seamless experience. It provides various services like storage, networks, development tools, Analytics tools, infrastructure, and many more. Benefits Of Deploying Web Applications on Google Cloud Pl 4 min read How to Deploy Node.js Express Application on Render ? Deploying a Node.js Express application on Render is straightforward and involves a few key steps to set up your project, configure deployment settings, and manage your application on the Render platform. Render provides an easy-to-use platform for deploying applications, offering features like auto 4 min read Deploying Node.js Applications Deploying a NodeJS application can be a smooth process with the right tools and strategies. This article will guide you through the basics of deploying NodeJS applications.To show how to deploy a NodeJS app, we are first going to create a sample application for a better understanding of the process. 5 min read Deploying A Node.js Application In kubernetes Kubernetes, or K8s, is an open-sourced container orchestration technology that is used to automate the manual processes of deploying, managing, and scaling applications with the help of containers. Kubernetes was originally developed by engineers at Google, and In 2015, it was donated to CNCF (Cloud 9 min read Deploy a Node.js Application with Azure Deploying a Node.js application on Azure, a prominent cloud computing platform, has become a seamless process, thanks to its user-friendly interface and integration capabilities. This guide aims to walk you through deploying a Node.js application on Azure using the Azure portal. We will cover essent 4 min read Like