I used pg_isready -h localhost which gives output as localhost:5432 - accepting connections
But when i used my host-ip instead of localhost ,it gives output as
pg_isready -h 18.191.7.185
output is 18.191.7.185:5432 - no response
My localhost isn't my ip-address?
No, it isn't. Verify with
ping localhost
which will show you the IP address that localhost resolves to.
The “loopback interface” is a special network interface that only contains your computer.
The cause of the problem is probably that the PostgreSQL parameter listen_addresses, which specifies the network interfaces on which PostgreSQL is listening, is set to the default value localhost.
Change the value to * and restart PostgreSQL, and it should work.
A second possibility is that you have restrictive firewall settings on your machine. Actually, reading your question again, that is probably your problem, since you are receiving no response rather that an error saying that nothing is listening on that port.
Related
I want to check if a server name like ".\INSTANCE" points to a local sql server instance. Currently I check the first part for certain strings, which are:
.
::1
[::1]
localhost
127.0.0.1
(local)
the computer name
additionally I could check for all installed network adapters IPv4 and IPv6 addresses
Since I didn't find this list anywhere and I see no clear scheme (e.g. (localhost) and local do not work) I'm not sure if there are any other possibilities. So the question is: Is this list complete or what am I missing?
Background
I am making a .bat file work with remote hosts.
This .bat file uses ping to test IP reachability.
I want to test the behavior of this script.
For nominal scinarios, I can use localhost.
For non-nominal scinarios, I tried using IP address reserved for documentation (e.g. 192.0.2.1), but ping command returned Request timed out rather than Destination host unreachable.
Question
Is there any IP address that always returns Destination host unreachable and Destination net unreachable ?
Edit
For example, when my IP is 192.168.1.2/24, I might be able to use ping 192.168.1.100 for Destination host unreachable scinario.
But this test will fail if 192.168.1.100 is leased with DHCP. Also this test will fail if my IP is 10.1.1.2/24.
I want to make all the tests successful in any environments.
Edit 2
This .bat file work with .xlsx files on remote hosts. Excel 2010 has a defect on handling of files in unauthenticated shared directories (Excel will hang with them), so I want to make sure the remote host is IP reachable and the target path is accessible.
To check IP reachability, this .bat file uses ping.exe to test IP reachability. I think users of this .bat file can use the result of ping.exe to break down the problem.
For example, if ping.exe returns Destination host unreachable and it worked properly in yesterday, the remote host was shutted down or freezed.
Or if ping.exe returns Destination net unreachable and it worked properly in another network, the problem will be on the network, not the remote host.
The behavior of ping.exe is different according to IP reachability.
In IP reachable case (This is a nominal scinario), ERRORLEVEL of ping.exe will be 0 and the output will contain TTL=.
In Destination host unreachable case (This is a non-nominal scinario), ERRORLEVEL of ping.exe will be 1.
In Destination net unreachable case (This is another non-nominal scinario), ERRORLEVEL of ping.exe will be 0 and the output will not contain TTL=.
I want to test the handling of the results of ping.exe on these three scenarios.
To IP reachable case, I can use localhost as the target IP address.
To Destination host unreachable case, I might be able to use an unallocated IP address on the same subnet. But such test will fail if the target IP address is leased with DHCP, or the test environment is moved to another subnet. I want to make all the tests successful in any environments.
This is the same with Destination host unreachable case.
If no result is returned, there is no way of knowing whether the address was reachable or non existent, because both are not reachable.
If you send out a ping and the response is unanswered, how are you supposed to know why? It may not have been answered because the intended host no longer exists but the host or DN servers may have technical issues. Unless the respective servers have some form of auto response setup informing the pinger of the reason why they're not responding, all you will know is that they're not reachable, (and and auto response is still a response).
"The host timed out" only informs you that a response didn't return within a specific response period, not of a reason why!
I've been doing some Sybase stuff on Linux and have bcp in's and out's working great. Here's my working bcp out on linux:
bcp drd02.dbo.APPL_ENVIRONMENT out APPL_ENVIRONMENT.bcp -U sa -P SyAdmin -n
When trying the same in Windows, I get the following error:
ct_connect(): network packet layer: internal net library error: Net-Lib protocol
driver call to connect two endpoints failed
Here's a few pertinent details:
I can connect to my server via iSQL GUI. Its shown as Sybase157 0.0.0.0 5000 and my Drd02 database is online and available.
Contents of the c:\sybase\ini\sql.ini are (I added the drd02 lines):
[Sybase157_XP]
master=NLWNSCK,0.0.0.0,5001
query=NLWNSCK,0.0.0.0,5001
drd02=NLWNSCK,0.0.0.0,5001
[Sybase157]
master=NLWNSCK,0.0.0.0,5000
query=NLWNSCK,0.0.0.0,5000
drd02=NLWNSCK,0.0.0.0,5000
[Sybase157_JSAGENT]
master=NLWNSCK,0.0.0.0,4900
query=NLWNSCK,0.0.0.0,4900
The environment variables are:
%DSQUERY%=Sybase157
%SYBASE%=c:\Sybase
No matter what I try, it's just not connecting. I'd be happy for any help that could be provided.
I figured it out. The fact that i could get into isql with the IP address made me think that maybe 0.0.0.0 is somehow not available to Bcp.
I modified c:\sybase\ini\sql.ini with the following:
from:
[Sybase157]
master=NLWNSCK,0.0.0.0,5000
query=NLWNSCK,0.0.0.0,5000
drd02=NLWNSCK,0.0.0.0,5000
to:
[Sybase157]
master=NLWNSCK,123.123.123.123,5000
query=NLWNSCK,0.0.0.0,5000
drd02=NLWNSCK,0.0.0.0,5000
after putting my public IP address of my vm in the sql.ini, bcp was able to speak to it correctly.
I should mention this was just a one-time fix to make it work, making this change will probably mess up external connections to the db. You'd need a loopback adapter or something to make this work right.
I have a website on HostGator and a dedicated server of my own running SQL Server 2008R2.
The connection string I use is X.X.X.X,1433 which points to the IP address of my dedicated server.
I have made the firewall settings on my server so that I can use SSMS & log into SQL Server from my home PC.
Having done that, I was under the impression that connecting to SQL from my hostGator hosted-site would work just fine.
I receive the following error:
A network-related or instance-specific error occurred while establishing a
connection to SQL Server. The server was not found or was not accessible.
Verify that the instance name is correct and that SQL Server is configured to
allow remote connections. (provider: TCP Provider, error: 0 - An attempt was
made to access a socket in a way forbidden by its access permissions.)
I have looked up this error and found many explanations, but not one dealing with my circumstances.
My server is running Windows 2008 w/IIS 7.5. I was assured by HostGator tech support that there would be no problems from their end.]]
My firewall allows TCP port 1433, & the UDP port 1434 for the SQL Server Browser service.
Since I have a dedicated server, I have no one to ask this question to from my hosting company.
I had a similar issue with Docker for Windows and Hyper-V having reserved ports for its own use- in my case, it was port 3001 that couldn't be accessed.
The port wasn't be used by another process- running netstat -ano | findstr 3001 in an Administrator Powershell prompt showed nothing.
However, netsh interface ipv4 show excludedportrange protocol=tcp showed that the port was in one of the exclusion ranges.
I was able to follow the solution described in Docker for Windows issue #3171 (Unable to bind ports: Docker-for-Windows & Hyper-V excluding but not using important port ranges):
Disable Hyper-V:
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
After the required restarts, reserve the port you want so Hyper-V doesn't reserve it back:
netsh int ipv4 add excludedportrange protocol=tcp startport=3001 numberofports=1
Reenable Hyper-V:
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
After this, I was able to start my docker container.
Just Restart-Service hns can change the ports occupied by Hyper-V. It might release the port you need.
Per this link:
the symptom could occur if the replication service tries to use the ports that occupied by others, or by a malfunction NIC. Please try the following steps:
Restart the windows firewall service
Reboot the problematic machine
Restart the “TCP/IP stack”. Run CMD as administrator, type “netsh int ip reset resetlog.txt” to reset TCP/IP.
Try to temporarily disable antivirus.
Not surprisingly, this error can arise when another process is listening on the desired port. This happened today when I started an instance of the Apache Web server, listening on its default port (80), having forgotten that I already had IIS 7 running, and listening on that port. This is well explained in Port 80 is being used by SYSTEM (PID 4), what is that? Better yet, that article points to Stop http.sys from listening on port 80 in Windows, which explains a very simple way to resolve it, with just a tad of help from an elevated command prompt and a one-line edit of my hosts file.
My windows firewall was blocking port 8080 so i changed it to 5000 and it worked!
As per https://stackoverflow.com/a/33859341/446250, having internet connection sharing enabled for my ethernet adapter ended up causing this problem for me. Disabling the sharing fixed the problem
My situation and solution: I had created and enabled a HyperV ethernet adapter. For some reason, my main windows machine was using the "virtual" ethernet adapter instead of the 'hardware' adapter.
I disabled the virtual ethernet and my network settings to change the network public/privacy settings were revealed.
If You need to access SQL server on hostgator remotely using SSMS, you need to white list your IP in hostgator.
Usually it takes 1 hour to open port for the whitelisted IP
For others who get this error but have a slightly different cause, you can do the following to troubleshoot. Open a text editor by right clicking and choosing Run As Administrator. Open C:\Program Files\pgAdmin 4\v4\web\pgAdmin4.py and add one line of code without anything else. The output will be drastically different and helpful. You can find the error in the system tray > pgAdmin > View Log.
import traceback # <--- add this line too.
try:
app.run(
host=config.DEFAULT_SERVER,
port=config.EFFECTIVE_SERVER_PORT,
use_reloader=(
(not app.PGADMIN_RUNTIME) and app.debug and
os.environ.get("WERKZEUG_RUN_MAIN") is not None
),
threaded=config.THREADED_MODE
)
except IOError:
#app.logger.error("Error starting the app server: %s", sys.exc_info())
app.logger.error("Error starting the app server: %s", traceback.format_exc()) # <--- add this line!
Instead of this:
ERROR flask.app: Error starting the app server: (<class 'OSError'>, OSError(10013, 'An attempt was made to access a socket in a way forbidden by its access permissions', None, 10013, None),
You will get this:
2021-03-01 11:38:33,817: ERROR flask.app: Error starting the app server: (<class 'OSError'>, OSError(10013, 'An attempt was made to access a socket in a way forbidden by its access permissions', None, 10013, None), <traceback object at 0x00000279EF74A3C0>)
Traceback (most recent call last):
File "C:/Program Files/pgAdmin 4/v4/web/pgAdmin4.py", line 210, in main
app.run(
File "C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages\flask\app.py", line 943, in run
run_simple(host, port, self, **options)
File "C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages\werkzeug\serving.py", line 1052, in run_simple
inner()
File "C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages\werkzeug\serving.py", line 996, in inner
srv = make_server(
File "C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages\werkzeug\serving.py", line 847, in make_server
return ThreadedWSGIServer(
File "C:/Program Files/pgAdmin 4/v4/venv/Lib/site-packages\werkzeug\serving.py", line 740, in __init__
HTTPServer.__init__(self, server_address, handler)
File "C:/Program Files/pgAdmin 4/v4/venv/Lib\socketserver.py", line 452, in __init__
self.server_bind()
File "C:/Program Files/pgAdmin 4/v4/venv/Lib\http\server.py", line 138, in server_bind
socketserver.TCPServer.server_bind(self)
File "C:/Program Files/pgAdmin 4/v4/venv/Lib\socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions
I was able to solve an identical error message on a local Analysis Services instance by turning off loopback address filtering in the firewall.
Nothing worked for me. Grep couldn't find the culprit listener. Resetting TCP / IP or Firewall didn't do anything either. The following command solved it:
net stop http
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?
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.
The error means the OS of the listening socket recognized the inbound connection request but chose to intentionally reject it.
Assuming an intermediate firewall is not getting in the way, there are only two reasons (that I know of) for the OS to reject an inbound connection request. One reason has already been mentioned several times - the listening port being connected to is not open.
There is another reason that has not been mentioned yet - the listening port is actually open and actively being used, but its backlog of queued inbound connection requests has reached its maximum so there is no room available for the inbound connection request to be queued at that moment. The server code has not called accept() enough times yet to finish clearing out available slots for new queue items.
Wait a moment or so and try the connection again. Unfortunately, there is no way to differentiate between "the port is not open at all" and "the port is open but too busy right now". They both use the same generic error code.
If you try to open a TCP connection to another host and see the error "Connection refused," it means that
You sent a TCP SYN packet to the other host.
Then you received a TCP RST packet in reply.
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://www.rfc-editor.org/rfc/rfc793 page 69:
SYN-RECEIVED STATE
If the RST bit is set
If this connection was initiated with a passive OPEN (i.e., came
from the LISTEN state), then return this connection to LISTEN state
and return. The user need not be informed. If this connection was
initiated with an active OPEN (i.e., came from SYN-SENT state) then
the connection was refused, signal the user "connection refused". In
either case, all segments on the retransmission queue should be
removed. And in the active OPEN case, enter the CLOSED state and
delete the TCB, and return.
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...
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.
1.Check your server status.
2.Check the port status.
For example 3306 netstat -nupl|grep 3306.
3.Check your firewalls.
For example add 3306
vim /etc/sysconfig/iptables
# add
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
Although it does not seem to be the case for your situation, sometimes a connection refused error can also indicate that there is an ip address conflict on your network. You can search for possible ip conflicts by running:
arp-scan -I eth0 -l | grep <ipaddress>
and
arping <ipaddress>
This AskUbuntu question has some more information also.
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.
In Ubuntu, Try
sudo ufw allow <port_number>
to allow firewall access to both of your server and db.
From the standpoint of a Checkpoint firewall, you will see a message from the firewall if you actually choose Reject as an Action thereby exposing to a propective attacker the presence of a firewall in front of the server. The firewall will silently drop all connections that doesn't match the policy. Connection refused almost always comes from the server
In my case, it happens when the site is blocked in my country and I don't use VPN.
For example when I try to access vimeo.com from Indonesia which is blocked.
Check if your application is bind with the port where you are sending the request
Check if the application is accepting connections from the host you are sending the request, maybe you forgot to allow all the incoming connections 0.0.0.0 and by default, it's only allowing connections from 127.0.0.1
I had the same message with a totally different cause: the wsock32.dll was not found. The ::socket(PF_INET, SOCK_STREAM, 0); call kept returning an INVALID_SOCKET but the reason was that the winsock dll was not loaded.
In the end I launched Sysinternals' process monitor and noticed that it searched for the dll 'everywhere' but didn't find it.
Silent failures are great!