Explore Courses Blog Tutorials Interview Questions
0 votes
in GCP by (29.3k points)

Created VPS using the GCE platform. In the instance, MongoDB database that is hosted at the default port 21017.And  also set up a REST API based NodeJS server with express listening in on port 8080.

Now, NodeJS site can only accessed internally. How do I expose port 8080 to the external ip address,  through which  I can access the API anywhere?

1 Answer

0 votes
by (50.2k points)

By default, the incoming traffic is blocked by GCE you need to open the firewall rules, where you need to open up port 8080. You can use the below command for the ingress rule.

gcloud compute firewall-rules create rule-allow-tcp-8080 --source-ranges --target-tags allow-tcp-8080 --allow tcp:8080

gcloud compute instances add-tags VM_NAME --tags allow-tcp-8080 

For more details, refer to the below tutorial on google cloud training.

Related questions

Browse Categories