Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection refused / couldn't connect to host

Tags:

curl

I have a process that is running on a specific port on my remote Ubuntu machine and I'm exposing that port via HTTP. When I tried to connect with my client using curl, I'm not able to connect, but if I do the same call on the remote machine locally, I can see that it connects. So I'm pretty sure that it is a network issue, but just not sure what it is?

Even trying on the remote host, I get the same error if I give the actual IP address of the machine!

Joes-MacBook-Pro:~ joe$ curl --verbose --insecure --cert .docker/cert.pem --key .docker/key.pem https://my.ip.address:1234/images/json  
* About to connect() to my.ip.address port 1234 (#0)  
*   Trying my.ip.address... Connection refused  
* couldn't connect to host  
* Closing connection #0  
curl: (7) couldn't connect to host  
Joes-MacBook-Pro:~ joe$ 
like image 600
joesan Avatar asked Nov 23 '14 19:11

joesan


People also ask

What is connection refused by host?

A "Connection Refused" error will occur if your client sends a connection request to a remote server host, and the remote host responds to say that it refuses to accept the request. The "Connection Refused" error essentially means that the computer is not accepting connections to the requested IP address and port.

Can't connect to remote host connection refused?

This occurs when the firewall in between is rejecting the connections. For example, when a firewall is restricting connections, customers see the following error. This indicates that the firewall is preventing connections to the remote host's specified port.


2 Answers

Please check your curl version first if it's greater than 7.33.0-3

Downgrade curl to 7.33.0-3. There is a known bug that is now fixed and should be released with the next version. I got bit by this too.

Reference Link : https://bbs.archlinux.org/viewtopic.php?id=175433 http://sourceforge.net/p/curl/bugs/1319/

like image 50
Keshav Kalra Avatar answered Oct 25 '22 21:10

Keshav Kalra


I think i meet the same problem. At last I tried another port, and it worked. So maybe you can change the port.

like image 1
Peng Liu Avatar answered Oct 25 '22 22:10

Peng Liu