Node js deployement in Azure server could not be accesses outside using ip - node.js

I tried deploying a simple node js service in azure ubuntu using CLI,console logs says the server is up on port 8080(this same service works perfectly in my local machine),but when i tried to access the public ip from outside,it gives site can't be reached
Following was the output when i deployed my service
azureuser#myVM:~/drugdemo/user_service/drulistService$ vi server.js
azureuser#myVM:~/drugdemo/user_service/drulistService$ node server.js
App is listening on 8080
^C^C
azureuser#myVM:~/drugdemo/user_service/drulistService$ pm2 start server.js
[PM2] Starting
/home/azureuser/drugdemo/user_service/drulistService/server.js in fork_mode (1 instance)
[PM2] Done.
Use `pm2 show <id|name>` to get more details about an app
azureuser#myVM:~/drugdemo/user_service/drulistService$
Please help me with your suggections.
(I already tried changing 'localhost' to '0.0.0.0' and '127.0.0.1' but didn't work for me)
Thank you in advance

Make sure to open the firewall port via Azure as well and not just the server.
This may help: https://blogs.msdn.microsoft.com/pkirchner/2016/02/02/allow-incoming-web-traffic-to-web-server-in-azure-vm/

Related

Access NodeJS server installed on Linux server

I created my App from this boilerplate
https://github.com/Bikranshu/express-react-boilerplate
Now I uploaded it to a live Linux server and Node server is running.
Screenshot of running server
But I am unable to access it through Browser with IP address of server.
http://ip_address:3000
After waiting long in browser it is showing timeout error.
Please guide me how can I access the node/react app from browser.
Server running at <ipaddress> is a local IP, are you in a different network than the server? If so, you should be typing https://<public ipaddress>:3000
UPDATE
Hosting services usually only forward port 80 (http) or 443 (https.) This means that your port 3000 is not allowed for public access. To fix your problem you need to change the listening port.
Check line 42 on
server/app.js change 'port' to "80" or check package.json and edit npm start to set port to 80

How to node js app move to production see on live api data

I tried to sucessfully bulid node js api using crud Operation and working fine in locally.but how to move production to live see the api data.I tried pm2 but also working for local ipaddress.how to solve this problem any solution..
Change the host name in server.js or index.js file from 'localhost' to 0.0.0.0 then you server will expose to the outside of the your network
Change 'localhost' to '0.0.0.0'
If you have any firewalls you must allow your server port to outside network.
If you are using pm2, you can select environment as production while starting the process.
pm2 start config.js --env production
Ref: http://pm2.keymetrics.io/docs/usage/environment/

How can I change the ip and port of pm2 web interface?

pm2 web interface - $pm2 web - listen on all the ip available on the machine and I would like it to only listen on localhost or ip of my choice.
$pm2 web
Launching web interface on 0.0.0.0:9615
[PM2][WARN] Applications pm2-http-interface not running, starting...
[PM2] App [pm2-http-interface] launched (1 instances)
[PM2] Process launched
pm2 version 2.1.6
node version 4.7.3
Thanks
EDITED:
I have researched about the environment variables and for the ip and port are:
"env_production" : {
"NODE_ENV": "production",
"PM2_API_IPADDR" : "IP here",
"PM2_API_PORT" : "PORT here"
},
I have tried to start the web interface using the ecosystem.json file and I can not get it.
I am going to open another question on this subject.
How to start pm2 http web interface using the ecosystem.json file?
To start the pm2 web interface with a different port and/or different listening address you can run it with the environment variable you found set.
eg. PM2_API_PORT=1234 PM2_API_IPADDR=192.168.1.1 pm2 web
I recommend setting the environment variables in your ecosystem.json file.
So for example, I usually set NODE_ENV to be production / development or PORT to be 8080 and maybe, in your case, HOST to be localhost.
To access them in your node application, use process.env.<ENVIRONMENT VAR HERE>.
So for example in your javascript: var port_num = process.env.NODE_ENV;
Here's the pm2 documentation on how to set the environment variables, under the env property: http://pm2.keymetrics.io/docs/usage/deployment/

Running node app digitalocean and accessing it

Im running my node app with grunt on a DO droplet. I start the server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:3000
But when I navigate to my dropletIP:3000 I cannot see the app, I get:
This site can’t be reached
mydropletIP refused to connect.
Shouldn't my app be available? I don't have nginx or anything installed.
I was having similar problem but the solution was simple. Change from 'localhost' to '0.0.0.0' i.e
.listen(8080, '0.0.0.0');
And then to test your api just enter your static ip of droplet with port that you have entered i.e droplet-ip:8080
Check the particular port is opened or not ,using following command
sudo ufw status
If any Firewall enabled and any port is block means you can see that.
netstat -an | grep "LISTEN " ( List of listening port on server)
I need this info ,then only we can find a problem

How to access stronglooop loopback application which is running on a subfolder on live server

I have installed strongloop loopback application on a live server on domain e.g: www.abc.com . I have created stronglooop loopback project in a subfolder called "lb" After successfull creation I executed the command "slc run" the terminal logs that your loopback app is running on http://localhost:3000 but when I opened www.abc.com/lb or www.abc.com:3000/lb... it was not running there ... What mistake I did? thanks in advance.
Your loopback running on same domain but on another port so you can access it by http://www.example.com:3000
It's doesn't matter which folder your application is stored. When you run it, by default it runs on default domain on port 3000.
You should be able to deploy your app to that server using the command:
$ slc deploy http://user:pass#prod1.example.com:3000
This is also documented here

Resources