Error code: ERR_CONNECTION_REFUSED running first node app on Vagrant OSX10.5


#1

After following this intro here http://www.aerospike.com/docs/client/nodejs/examples/node_express_aerospike.html, I ran my first node app and got this error from my browser when browsing to http://localhost:9000

Have anyone experienced that?


#2

Hi Joe,

This error indicates that your web browser is unable to connect to the local Http web server over port 9000.

Are you running your Nodejs application within a VM, or Vagrant? Could you post the steps you did to start your application. Any other applications using port 9000? Also ensures that your application is running outside of the vagrant container.

best, –Lucien


#3

Running the example on my mac book. I got the following:

  1. Started Aerospike Vagrant in the Vagrant folder with vagrant up

  2. Ran the **node app** command in the nodejs app folder.

    luciens-mbp:node-express-aerospike-app lucien$ node app Connection to Aerospike cluster succeeded! App is running on http://localhost:9000. Press Ctrl-C to exit…

  3. Used Chrome browser to get the HTML form at http://localhost:9000


#4

@lucien thanks for the response. Yes, I ran my node app from inside Vagrant’s aerospike centos-6.5 box, since that’s the option for MacOS no?


#5

@lucien yes I’ve got what you got up to step 2. Got the ERR_connection_refused from all browsers on step 3.


#6

@jochasinga, I think that’s the problem. You should run your **node app** from outside the vagrant container on your main host. If you want to run it in vagrant you will need to enable port forwarding on port 9000 for your vagrant VM.

you can edit Vagrantfile in the vagrant folder and add the port forwarding info:

Create a forwarded port mapping which allows access to a specific port

within the machine from a port on the host machine. In the example below,

accessing “localhost:8080” will access port 80 on the guest machine.

config.vm.network “forwarded_port”, guest: 9000, host: 9000

You basically have two options:

Option 1) Run the App from the main host and run only the database on vagrant VM.

Option 2) Run it all on the vagrant VM and enable port forwarding to be able to access Node app service over port 9000 from your web browser.


#7

I am using Windows 8.1 64 bits and also had the same problem (“ERR_CONNECTION_REFUSED”) that only happened on Google Chrome. On clicking on the “Detail” on the right of the error message, the problem lies with “127.0.0.1”, in my case. So I went to the settings and opened “Manage search engines …” box in the Search section, and while scrolling down, I saw that “Google Desktop, 127.0.0.1” was made a “Default”, so I switched over to Google as the default. Hope that might be of any help. ERR_CONNECTION_REFUSED – Solutions Encyclopedia