I'm trying to follow the redis cluster tutorial but whenever I try to run:
./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 \
127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005`
I get the error:
[ERR] Sorry, can't connect to node 127.0.0.1:7000
The server is running and I can connect to port 7000 using
redis-cli -p 7000
What am I missing?
Turns out I had REDIS_URL set in .bashrc from a previous project. Apparently the redis gem was setting the password from that url for ALL redis connections (even though I was not using the url for my cluster).
Thanks to soveran for pointing out this posibility in this question
Related
i have installed Postgresql and struggling to configure it, tried reinstalling but still facing issue, i removed all the files and then installed postgre 9.6 version, but getting below issues.
9.6 main 5432 down postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log
When i try to run postgre by using sudo -u postgres psql it gives below output
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
i have tried from other questions as well but can't fix the problem.
Very likely your PostgreSQL client is configured with a different socket directory (/var/run/postgresql) than your server. Check the unix_socket_directories configuration parameter in postgresql.conf.
Chances are that the server is listening on the default dirextory /tmp. Try
psql -h /tmp ...
Of course it could also be that the server is listening on a different port, e.g. 5555 (configuration parameter port). Then run
psql -p 5555 ...
I have a Node.js application where I use Redis, I am trying to connect the Docker container and the locally running Redis.
Tried solutions:
vim /usr/local/etc/redis.conf
Updated
bind 127.0.0.1
To
bind 0.0.0.0
Stopped the redis and start it again and tried running the docker
With the above thing tried running docker run -p 4000:8080 -p 6379:6379 -t node-app
Both above didn't worked getting the below error
Error: Redis connection to localhost:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
Update: I am checking it on Mac.
In Dockerfile add this
Docker v19.03
ENV REDIS_HOST "redis://host.docker.internal"
when i using it on node.js
const REDIS_HOST = process.env.REDIS_HOST ? process.env.REDIS_HOST : ""
const client = redis.createClient(REDIS_HOST)
"docker.for.mac.localhost" instead of localhost or '127.0.0.1' will work :), it worked for me on mac machine.
If you use default networking (--network="bridge"), you could simply use the IP address of the gateway between the Docker host and the bridge network, i.e. 172.17.0.1. Here is the documentation. This would work on all platforms, not only on a Mac.
You just need to set the docker internal host in your node app's config.json file:
"redisHost": "host.docker.internal"
You don't need to change any Redis configuration on your local.
I am trying to connect to my database on heroku, which I would use on my app. I'm using either Command Line or Git Bash on windows.
I have created database on heroku named postgresql-rectangular-87454 and installed Postgres without any errors.
Typing heroku addons I'm making sure, database is set up:
$ heroku addons
Add-on Plan Price State
──────────────────────────────────────────────── ───────── ───── ───────
heroku-postgresql (postgresql-rectangular-87454) hobby-dev free created
└─ as DATABASE
but when I try to connect it via heroku pg:psql or also heroku pg:psql postgresql-rectangular-87454 --app salty-shelf-36209, I get this error:
$ heroku pg:psql
--> Connecting to postgresql-rectangular-87454
psql: could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "ec2-54-225-97-112.compute-1.amazonaws.com" (54.225.97.112) and accepting
TCP/IP connections on port 5432?
Any advice would be appreciated. Thank you!
Without knowing more, my first guess would be network rules -- that the connection is being blocked by a local firewall. The pg:psql command simply grabs the DATABASE_URL from your application config and passes the connection string to your local psql command to create the connection. If you're behind a corporate firewall, you may need to speak with your IT department about making an outbound connection.
io.adapter(redis({ host: config.redisHost, port: config.redisPort }));
Both the confif.redisHost and config.redisPort are the correct values, but when I try to connect from my code I get the error -
'Error: Redis connection to 104.xxx.xx.xxx:6379 failed - connect ECONNREFUSED 104.xxx.xx.xxx:6379'
In redis.conf I've changed the bind to 0.0.0.0 as well as removing it completely and I've also tried setting protected mode to off just to try and get the connection working.
The IP and port are definitely, correct. Does anyone know why I might not be able to access the server from my code? My code is just being ran on my local machine and the redis server is being ran on a digital ocean ubuntu 14.04 machine. The status of the server is definitely running and I can access the redis-cli from the machine itself.
For some reason, it wasn't using redis.conf when I tried starting the server, I had to manually tell it to use it when starting up, now it's working.
I am trying to setup a redis server following this guide to provide shared sessions for my Elastic Beanstalk.
I've installed redis on a new ec2 instance, and it's working fine, locally. However, when I tried to connect the project from my Beanstalk to my redis server, I am getting a "connection refused" error.
After some poking around, I found out that my redis only listens to local (I think?)
netstat -l
tcp 0 0 localhost:6379 *:* LISTEN
I have already out bind 0.0.0.0 to /etc/redis/6379.conf, but I suspect that redis is not reading the same configuration file.
My questions:
How do I check if my redis server is actually loading the configuration file? I tried typing spam into the file and sudo service redis_6379 restart expecting errors, but redis starts normally.
Is there another way for me to configure redis to listen to all connections from my VPC?
Edit: Found my answer.
To find out what configuration file is loaded: redis-cli -p 6379 info server
There's 2 parts of the configuration file that I need to change, firstly bind 0.0.0.0 and comment the bind 127.0.0.1 that comes after.
On Linux Ubuntu server 20.04 LTS I was running into a similar issue after reboot of the EC2 server, for me what resolved it (my nodeJs app was running as Ubuntu user I needed to make that path available) was to add to the PATH within /etc/crontab by:
sudo nano /etc/crontab and just comment out the original path in there so you can switch back if required (mine was: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin ) and replace it with:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/ubuntu/.nvm/versions/node/v12.20.0/bin and that error disappeared for me