Search code examples
node.jsubuntu-16.04ubuntu-servergoogle-cloud-console

cannot access nodeJS REST API on google cloud ubuntu 16.04 instance but I can ping on the public IP successfully


I have a Ubuntu 16.04 instance on google cloud and I can ping the instance with it's public IP, I'm trying to run a nodeJS backend REST-API on it.. I have successfully check API on my local machine, along with mongoDB.

In terminal connection I can see nodeJS my server (API) is running, but I cannot access to it. I have try API calls by using web browsers and postman, but it giving following error after few seconds delay "Could not get any response - There was an error connecting to :" how to solve the issue and what might be the cause for this problem.


Solution

  • You need to open the necessary port in firewall rules section

    Go to -> Cloud console -> Networking -> VPC networks -> Firewall Rules

    Click create Firewall rules, Add a name, keep the rest in default and in the source ip ranges add 0.0.0.0/0 and in the Specified protocols and ports add tcp:<"your app port">