I'm trying to write a server program in C, using another client, I get this error when I try to connect through port 2080 for example.
connection refused
What can be the reasons of this error?
I'm trying to write a server program in C, using another client, I get this error when I try to connect through port 2080 for example.
connection refused
What can be the reasons of this error?
If you try to open a TCP connection to another host and see the error "Connection refused," it means that
RST is a bit on the TCP packet which indicates that the connection should be reset. Usually it means that the other host has received your connection attempt and is actively refusing your TCP connection, but sometimes an intervening firewall may block your TCP SYN packet and send a TCP RST back to you.
See https://tools.ietf.org/html/rfc793 page 69:
In Ubuntu, Try
sudo ufw allow <port_number>
to allow firewall access to both of your server and db.Check at the server side that it is listening at the port 2080. First try to confirm it on the server machine by issuing telnet to that port:
telnet localhost 2080
If it is listening, it is able to respond.
I get the same problem with my work computer. The problem is that when you enter localhost it goes to proxy's address not local address you should bypass it follow this steps
Chrome => Settings => Change proxy settings => LAN Settings => check Bypass proxy server for local addresses.
There could be many reasons, but the most common are:
The port is not open on the destination machine.
The port is open on the destination machine, but its backlog of pending connections is full.
A firewall between the client and server is blocking access (also check local firewalls).
After checking for firewalls and that the port is open, use telnet to connect to the ip/port to test connectivity. This removes any potential issues from your application.
Connection refused means that the port you are trying to connect to is not actually open.
So either you are connecting to the wrong IP address, or to the wrong port, or the server is listening on the wrong port, or is not actually running.
A common mistake is not specifying the port number when binding or connecting in network byte order...