Cannot connect from windows to redis linux server - linux

I cannot connect to redis server (ubuntu server 16.04 LTS 64 bits on separate PC) from windows 8.1 64-bits. Redis is well documented, however I found very little information how to connect redis server from separate machine.
I have installed latest version of redis into linux and locally everything works fine. I start server via redis-server and also I start redis-cli and after that I am able to add information into server and retrieve it. The same situation is in windows - everything works locally.
In order to connect from windows into linux redis server I did these changes.
In linux I set the static local IP via sudo nano /etc/network/interfaces
address 192.186.xxx.xxx
netmask 255.255.255.0
network 192.168.xxx.xxx
broadcast 192.168.xxx.xxx
gateway 192.168.xxx.xxx
dns-nameservers 8.8.8.8
In redis.conf file I bind my windows PC IP which is given by my internet service provider. I also opened TCP 6379 port in my router GUI. In windows I modify redis.windows-service.conf and redis.windows.conf files. In both of them I bind my IP address given by my internet service provider. After this I cannot start redis-cli properly (empty black cmd window is visible)
What I am doing wrong? I would be very grateful for any help.

You should modify the redis conf, my redis conf is located at /etc/redis/6379.conf.
And you should comment the line "bind 127.0.0.1" Or change to bind 0.0.0.0.
The bind specify which network interface the redis server should listen to. The default is localhost.
And also Change the protected-mode to no :
Protected mode is a layer of security protection, in order to avoid that
Redis instances left open on the internet are accessed and exploited.
When protected mode is on and if:
1) The server is not binding explicitly to a set of addresses using the
"bind" directive.
2) No password is configured.
The server only accepts connections from clients connecting from the
IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
sockets.
By default protected mode is enabled. You should disable it only if
you are sure you want clients from other hosts to connect to Redis
even if no authentication is configured, nor a specific set of interfaces
are explicitly listed using the "bind" directive.
protected-mode yes
If you don't disable the protected-mode, your redis server will not listen public ip interface. more detail see above.

If you can access the remote server from your machine, your problem is most probably with redis security config, read the Securing Redis section in this document
I found that most of the time people don't change the "bind" directive value in redis config, you can test that by setting bind 0.0.0.0 and restarting redis server, if that's the issue, you can then allow whatever subnets you need to access the server.

I have also experience the same issue trying to connect to Redis (MSOpenTech 3.0.5 and 3.2.1) By default if no binding is stated then redis(according to the comments in the conf file) will listen to all available interfaces. That said, v 3.2.1 does have 'bind 127.0.0.1' already set... in 3.0.5 Setting the binding to 'bind 127.0.0.1' still allows the redis-cli to be used. Binding to 192.168.1.2 renders the redis-cli unusable with both versions - there is no IP and Port prompt, simply a carat and the cli does not accept keyboard input. Binging to an external IP the MSOpenTech fork service will not restart and throws an error(nice). Clearing all bindings and reverting back to original state, the redis-cli becomes usable again. Also, on the MS OpenTech fork there is no 'ProtectedMode' setting in either config file. Not sure whether this can actually be set.
Have raised this as an issue on the MSOpenTech fork via github but expecting silence to be the only reply...
I'm not sure this helps you in any way other than knowing that you are not alone. I am trying to pub from PHP to AS3 subscribers - it works great in the Flash IDE but from the localhost browser, redis appears to go decididly deaf.

Related

How do I access RabbitMQ natively without IP address using amqplib?

Where I work we have a cloudfoundry server that provides RabbitMQ as a service. When I configure this service and try to connect using amqplib via (localhost, 127.0.0.1, etc) it doesn't connect. When I look at the Java project, it never configures an IP and seems to connect natively through a driver or something (using Spring).
How would I connect using amqplib without an IP? Should I use another node lib instead?
You can make a connection without setting the hostname but then the hostname is set as "localhost" as described in the documentation.
If your RabbitMQ is on a remote server you must provide
a remote IP address
port (if it is different from the default 5672)
username and password of not default user as mentioned here
You may not be able to make a connection due to closed port on the remote server is closed, check it via telnet

How to access CouchDB installed on another machine?

We have CouchDB installed on a separate machine.
When it was installed on my machine, it was accessible through Fauxton via link http://localhost:5984/_utils/index.html
Also, I am using Divan, a C# library to interact with CouchDB. It uses host as localhost and port as 5984 - default host and port names to connect with database.
But now I have CouchDB installed on another machine, how can I access it in this case?
Please suggest.
Thank you.
You need to allow exterior access in the new machine (which I'll just call the server). Your computer is the client. First, make sure the server is accessible from your network and get its IP address using ipconfig or ifconfig in the command line.
First, in the server, open the CouchDB configuration file, which is
/usr/local/etc/couchdb/local.ini in Linux
or
C:\Program Files\CouchDB\etc\couchdb\local.ini in Windows
and change
[httpd]
bind_address = 127.0.0.1
to
[httpd]
bind_address = 0.0.0.0
If there is no bind_address already in the file, just add it.
Then save the file.
Now, from the client, you can access futon from your machine using {SERVER_IP}:5984/_utils.
In Divan, set host to {SERVER_IP}. Unless you configure it otherwise, the port remains 5984.
Reference:
http://docs.couchdb.org/en/2.0.0/config/intro.html *
http://docs.couchdb.org/en/2.0.0/config/http.html *
(*) I'm assuming you're using CouchDB 2.0, but in my experience with 1.6.1 this instructions also work.
Connect to your server locally:
localhost:5984/_utils
then simply from the setting section, change the bind_address to 0.0.0.0

Redis cluster creating cannot connect to the server, what's wrong?

I have 3 different servers deployed on Aliyun, each of them is running 2 redis instances with port 6379 and 6380.
I was trying to build a redis cluster with these 6 nodes.(Redis version 3.2.0). But it failed and said "Sorry, cannot connect to the node 10.161.94.215:6379" (10.161.94.215 is the lan ip address of my first server.)
While obviously the servers were running quite well, and I could get it by redis-cli.
Gem is installed.
Requirepass is banned, no auth is needed.
No ip bind
No protected-mode as well.
error pic
All the configuration options about cluster are well set.
What's wrong with this?
I think i know why now.
Use the IP of the local host.
src/redis-trib.rb create 127.0.0.1:6379 127.0.0.1:6380 h2:p1 h2:p2 h3:p1 h3:p2
I think you are creating cluster from a different subnet. That might be a problem.
Looks like protected mode is a new security feature in redis 3.2. The short version is if you don't explicitly bind to an ip address it will only allow access to localhost.
If you only wish to create a cluster on a single host, this may be ok. If you're using multiple hosts to create a cluster you'll either need to turn off protected mode or explicitly bind to an ip address.
From redis.conf file:
# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
# "bind" directive.
# 2) No password is configured.
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode yes
There are instructions on how to correct this if you attempt to connect to it using something aside from the loopback interface:
DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
The output of redis-trib.rb is fairly terse (probably appropriately so).
sudo nano /etc/redis/6379.conf
Replace #bind 127.0.0.1 or bind 127.0.0.1 with bind 0.0.0.0
sudo service redis_6379 restart
Allow to access redis anywhere.

Setup MongoDB to be reachable from remote application

I have a web server that runs MongoDB. It will save some data that I need a second application installed in a different computer to be able to query on. The server with MongoDB is an Ubuntu, it will use Meteor (currently I'm just doing some tests, so I only have the MongoDB installed) and the other application is a NodeJS script with MongooseJS.
What should I do to setup that instance of MongoDB to be reachable from remote applications?
I'm actually finding it quite hard to understand and find information on the web. I tried
var connection = GLOBAL.database.host;
mongodb.connect('mongodb://'+GLOBAL.database.host);
But it's throwing an error Failed to connect to.... :27017
The host is a virtual machine on Koding that I set up to run these tests. How can I make sure Mongo is accessible and how can I ping it to see if the mongo is responding my requests?
By default MongoDB is restricted to allow connections only from 127.0.0.1 .
The configuration file of mongo is placed in /etc/mongod.conf. In that file you can find the following two lines:
# Listen to local interface only. Comment out to listen on all interfaces.
bind_ip = 127.0.0.1
Follow the instructions and go on commenting the bind_ip line (use the # symbol). Restart MongoDB and try again.
Make sure that you can reach your server to port 27017 (is the port that MongoDB uses). You'll have to allow it in your server if you have something like iptables or allow it in any firewall you may have.

grunt-connect not working when host is 0.0.0.0

I'm trying to externally access my local node.js development server that's created using the grunt-contrib-connect plugin. The server works (locally) when I use localhost or 127.0.0.1 as the hostname parameter. However, when I change the parameter to * or 0.0.0.0 in order to allow external access (as specified in the documentation), I cannot access the server either locally or externally; this is the error I get in Chrome:
I've tried disabling my firewall and I can see packets coming in from my phone on the correct port (which I'm using to attempt to access my local server externally).
Any ideas why it doesn't work to use * or 0.0.0.0 as the hostname?
Figured it out - when I specified * or 0.0.0.0 as the hostname parameter, I was able to connect externally - I just hadn't tried since I wasn't able to access it locally and assumed it wasn't working at all. Changing the address in the browser to localhost:9000 (instead of 0.0.0.0:9000, which it defaults to) when Grunt first opens the page allowed me to access my server locally.
You can set your own ip address instead of the 0.0.0.0.
With this grunt launch the server on your ip. You can use your mobile to.
The livereload will work on your desktop and on your mobile.
It's not the best way if your work by team because each one have his ip address but it's good enough if you work alone.

Resources