0

I am pretty new to sails module on node.js

I created a basic web-app and it launches good on http://localhost:8081/test

but when I try to access with my machine name like http://mymachinename:8081/test

it goes 404 page. I also tried to access from another PC in same domain and same 404 error.

I expect both requests should return 200 response.

Am I missing something?

Teoman shipahi
  • 47,454
  • 15
  • 134
  • 158

1 Answers1

1

Here is a little information and some suggestions. Here I am on MAC OS X.

First, yes it should work out of the box:

$ sails new app && cd $_ && npm install
$ sails lift --port 1338

http://127.0.0.1:1338/
http://192.168.0.5:1338/
http://mymachine.local:1338/

are all equivalent (loopback, my local IP, my local machine name respectively).

Try a port scan and see if the port you think it is running on is actually running or else already occupied.

On Mac OS X.

lsof -i :1337

Perhaps try starting on a different port:

sails lift --port 1338   (i did this for the above)

Did you install sails globally? If so, you could try uninstalling and reinstalling:

npm uninstall -g sails
npm install -g sails

If you are still having problems, they are local and very unlikely specific to SailsJS. Do usual troubleshooting for network / port related issues locally etc.

Finally, to gain access for other users to your local machine, i usually use ngrok. Ngrok exposes your localhost to the web - example:

$ npm install ngrok -g
$ ngrok http 1338

See this example usage:

enter image description here

In the above example, the locally running instance of sails at: localhost:1338 is now available on the Internet served at: http://840fa6c4.ngrok.io

arcseldon
  • 35,523
  • 17
  • 121
  • 125
  • Reference given by @xkcd149 lead me the answer but I will accept this answer since it goes similar walk-through for solution of the problem. Thanks. – Teoman shipahi Jan 07 '16 at 15:02
  • @Teomanshipahi - hey, thanks - appreciate it. And hope you enjoy SailsJS - i think it is pretty awesome and used it in production (commercially) in 2014 - improved since then. the IRC channel #sailsjs on chat.freenode.net is a good place to paste SOF questions too, there is usually someone knowledgeable on there ready to offer help / advice. – arcseldon Jan 07 '16 at 15:12
  • @Teomanshipahi - i have provided a little more context on ngrok usage - it was a refresher for myself also... been a while. – arcseldon Jan 07 '16 at 15:25