curl: (7) Failed connect to 127.0.0.1:5984; Connection refused [Sometimes] - linux

I have a couchdb database installed in a centos machine in azure. what's strange is that when i try to run 'curl http://127.0.0.1:5984' in terminal it give me expected result sometimes.
{"couchdb":"Welcome","version":"2.3.0","git_sha":"07ea0c7","uuid":"d36b551cb35122db8d088982c4216c9b","features":["pluggable-storage-engines","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
but sometimes i am getting this:
curl: (7) Failed connect to 127.0.0.1:5984; Connection refused
this is having frequently i means sometimes i get result and sometimes i don't.
what am i doing wrong??

Perhaps your virtual machine has iptables rule that deny the traffic go in to port 5984. Try to open with following command:
iptables -I INPUT -p tcp -m tcp --dport 5984 -j ACCEPT
If it still not working, try to turn off firewalld service:
service firewalld stop

Related

How to open port 80 for node server on local machine?

How can I use the port 80 on my local Linux machine as the port of my node server?
The netstat command netstat -ptuln says the following about this port, while the node server is running:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN -
I found on this site some recommendations for the command sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT. I executed this command but when I make a request with curl (curl 1.97.xxx.xxx.xx) it keeps responding with curl: (7) Failed to connect to xxxxxx port 80: Connection refused.
But using curl the following ways works: curl 0.0.0.0:80 or curl localhost:80.
My conclusion is, that I somehow have not opened the port correctly, but all I could find on the internet repetitively is the command I mentioned earlier.
I am aware of the fact that I could fix this easily by using an apache server, but I would like to make it without it.
Thank you!
Paste the output from
netstat -ptuln
command.I think the problem is that your web server runs on local address and can not be reachable for other machines in network.

P4V not connecting to my DigitalOcean Droplet when setting up a Perforce Server

I'm trying to set up a Perforce Server using a Droplet from DigitalOcean and connect to it via P4V.
I was following this tutorial https://allarsblog.com/2014/09/25/setup-perforce-digital/ which I was originally led to by an Unreal Engine official YouTube tutorial. When I got to the part where I was supposed to connect via P4V I got the following error:
Connect to server failed; check $P4PORT.
TCP connect to [Droplet IP Address]:1666 failed.
connect: [Droplet IP Address]:1666: WSAECONNREFUSED
I posted on the DigitalOcean forum and they suggested I try to set the P4PORT then verify it with p4 info, but the p4 info command only yields the following:
Perforce client error:
Connect to server failed; check $P4PORT.
TCP connect to devel:1666 failed.
No such host is known.
Since it said no such host is known, I tried using the direct IP Address in the place of devel, and that only returned the same result but it also said connect: [IP Address]:1666: WSAECONNREFUSED.
I can ping the IP Address just fine. Connecting via puTTY (port 22) does not seem to be an issue. I'm using Windows 10, I heard Firewalls could produce this problem but even if I disable my Firewall I get the same errors.
This is my first time doing this, so I may have made a beginners mistake. Any help would be appreciated.
Found my answer in another Forum: Fire up PuTTY and log in as “root” Type “p4d” from the command line (If you don’t see it, it should be located in “/usr/local/bin”)
I had a similar issue.
To clear the " WSAECONREFUSED " error we put Server:[DigitalOcean ServerIP]:1666 and clicked the "New" button for user.
We were prompted with a new error -> WSAETIMEDOUT
to solve this we had to open the 1666 port on the server so we opened the up and down 1666 using these commands.
iptables -I INPUT -p tcp --dport 1666 --syn -j ACCEPT
&
iptables -I INPUT -p udp --dport 1666 -j ACCEPT

curl: (7) Failed to connect to port 80, and 443 - on one domain

This question shows research effort; it is useful and clear
I have checked the cURL not working properly
When I run the command curl -I https://www.example.com/sitemap.xml
curl: (7) Failed to connect
Failed to connect on all port
this error only on one domain, all other domain working fine, curl: (7) Failed to connect to port 80, and 443
Thanks...
First Check your /etc/hosts file entries, may be the URL which You're requesting, is pointing to your localhost.
If the URL is not listed in your /etc/hosts file, then try to execute following command to understand the flow of Curl Execution for the particular URL:
curl --ipv4 -v "https://example.com/";
After many search, I found that Hosts settings not correct
Then I check nano /etc/hosts
The Domain point to wrong IP in hosts file
I change the wrong IP and its working Fine
This is new error Related to curl: (7) Failed to connect
curl: (7) Failed to connect
The above error message means that your web-server (at least the one specified with curl) is not running at all — no web-server is running on the specified port and the specified (or implied) port. (So, XML doesn't have anything to do with that.)
you can download the key with browser
then open terminal in downloads
then type sudo apt-key add <key_name>.asc
Mine is Red Hat Enterprise(RHEL) Virtual Machine and I was getting something like the following.
Error "curl: (7) Failed to connect to localhost port 80: Connection refused"
I stopped the firewall by running the following commands and it started working.
sudo systemctl stop firewalld
sudo systemctl disable firewalld
If the curl is to the outside world, like:
curl www.google.com
I have to restart my cntlm service:
systemctl restart cntlm
If it's within my network:
curl inside.server.local
Then a docker network is overlapping something with my CNTLM proxy, and I just remove all docker networks to fix it - you can also just remove the last network you just created, but I'm lazy.
docker network rm $(docker network ls -q)
And then I can work again.

cannot open up port using iptables to use rstudio server

I am currently trying to open port 8787 for rstudio server. I have set this up on an ubuntu host, and want to point my browser at the ip address of the ubuntu host, using port 8787 to direct it to rstudio. I can do this from the host machine, but no such luck using a different computer.
When I do
netstat - peantl | grep ":8787"
I get nothing returned, unlike when checking port 22 which is confirmed as listening. I can there ssh from external machines into the ubuntu host.
So I tried to open up port 8787 with iptables:
sudo iptables -A INPUT -p tcp --dport 8787 -j ACCEPT
command runs fine, but then re-checking with netstat I still do not get any output (I was expecting similar output to port 22 as mentioned previously)
I also allowed port 8787 on ufw:
sudo ufw allow 8787
using gufw it confirms port 8787 is open.
What could be the issue? If my network has restricted port 8787 how can I tell? Am I allowing port 8787 correctly with iptables?
Thanks.
All your iptables and ufw commands are doing is opening ports in the firewall itself. The fact that there is no output from the netstat|grep line means that the rstudio software does not actually have the port open for anyone to connect to. This is the issue you need to fix first.

ssh: connect to host X.X.X.X port 22: Connection timed out

I'm running a linux based (centos 6.5) VPS. I had no problem since yesterday that everything was fine . I was editing Iptables rules , trying to reject and allow some services and ports but suddenly I got disconnected from VPS and could not connect anymore. I Googled a lot and read many topics regarding this problem but none of them helped me.
I tried:
Reinstalling sshserver and client
Flushing Iptables, saving it and then restarting it
Changing the port for ssh using from /etc/ssh/sshd_config file to sth
else and then allowing this new port from iptables
but I still have the problem.
any help would be appreciated.
As we commented :
Put this rule : iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT

Resources