i am trying to connect to a PostgreSQL DB which is hosted on Windows 10 machine.
I have changed the following settings on ini file:
listen_addresses = '*' is set in postgresql.conf
host all all 0.0.0.0/0 md5 is set pg_hba.conf
I have enabled the 5432 port for TCP/IP connections and I have checked that it is listening.
Results:
IT WORKS when I try to connect to the DB from a machine that is under the same network as the machine hosting the server using the private IP for connection
IT DOES NOT WORK when I try to connect to the DB from a machine outside the network of the machine hosting the server, using the public IP for connection
I have seen several topics about it, but the only suggestions are to modify init file and add a rule to open TCP/IP on 5432 port.
Could you please help?
thanks!
Related
I set up a postgres 14 db on my windows server 2016 vps. I configured the port to be 5432 and set listen_addresses = '*' inside postgresql.conf and added host all all 0.0.0.0/0 md5 and host all all ::0/0 md5 to pg_hba.conf. I checked that the service was indeed running when opening the windows Services application and I restarted the service after every change. I also added a new inbound rule on the firewall to allow port 5432. And I've tried restarting my entire vps.
Whenever I try to connect to the postgres server remotely (psql -h <my vps ip address>), I get met with Connection timed out (0x0000274C/10060) Is the server running on that host and accepting TCP/IP connections?. Am I somewhere missing a step?
I cannot get my Azure VM with SQL Server to connect from anything other than the local machine. This is a Windows VM where I downloaded and installed SQL Server manually. I am at a loss.
If I RDP to the machine and connect to SQL Server it succeeds. If I attempt to hit it from any other box on my Virtual Network it will not connect. I can ping the box and the name resolves to the proper IP address. Test-NetConnection shows that I cannot connect on port 1433, but I can connect on other ports like 3389.
Here is all I've tried/confirmed thus far.
TCP/IP is enabled in configuration manager and set to listen on port 1433. Remote access is enabled in configurations.
I added a port 1433 Windows firewall rule for all 3 profiles.
I turned off the Windows firewall for all 3 profiles.
Confirmed both machines are definitely on the same virtual network.
The default NSG rule is in place for any port/protocol on the same Virtual Network.
I added an explicit NSG rule for the source IP of another machine to any port/protocol.
I modified the rule that allowed me to RDP to the box from my personal IP to include 1433 in addition to 3389. Test-NetConnection succeeds on 3389 and fails on 1433.
None of these made a difference.
I created a new VM where the machine came pre-installed with SQL Server. It connects just fine from any other machine on the VirtualNetwork without making any changes to any firewall or NSG rules.
What am I missing?
Is SQL listening on the internal address and an allowed connection IP? http://www.mohamedmostafa.co.uk/blog/2009/10/10/setup-configure-microsoft-sql-server-to-allow-remote-connection-remote-sql-management-studio-access/
Sound like your MSSQL is setup with a dynamic port in the tcp/ip protocol. Check the TCP/IP protocol and if the port is blank, set it to the desired port (1433) and set NSG to allow communication on this port.
I have to connect to a fresh SQL Server Express 2017 on a machine not part of my domain. I have configured
Mixed Mode Installation with sa with password
SSMS -> Server -> Properties -> Connections -> Allow remote connections
SQL Configuration Manager -> Instance "EXPRESS2017" -> TCP/IP: Enable and Active and Port 1438
Restarted the "SQL Server (EXPRESS2017)" service.
I now tried to access from a remote computer, and got a timeout. I then tried to connect from the local SSMS, which works without special settings, but when under options, forced "Protocol: TCP/IP" is set, with the same credentials as before, I also got a timeout.
So am I right that I can rule out the firewall or problems finding the instance, and everything points towards a configuration issue in TCP/IP protocol, or did I overlook some setting?
EDIT: I have disabled Windows firewall, and no other firewall is installed on the computer. I have restarted the computer. I also found this article about PortQry and had a check - locally:
C:\Users\Administrator\Downloads>PortQry.exe -n 172.17.41.124 -p UDP -e 1434
Querying target system called:
172.17.41.124
Attempting to resolve IP address to a name...
IP address resolved to WIN-AECL8CJVS7E.test.local
querying...
UDP port 1434 (ms-sql-m service): NOT LISTENING
EDIT: I have run NETSTAT and it seems no port in the 14xx range is open at all, although the SQL Server Browser service is running. I must be missing something there...
You did not show your connection string, but I suppose you use your instance name here.
In order to connect to SQL Server the network library has to know 2 things: IP address and a port. Your instance is named and uses non-default port 1438.
So your connection string should use 172.17.41.124,1438 as server name, or, alternatively, you can use instance name like this: 172.17.41.124\EXPRESS2017 but SQL Server Browser should run.
Unable to connect to SQL Server remotely
I have installed SQL Server 2014 Express on Windows 10. I can connect to server locally by entering: computername\SQLEXPRESS or 192.168.0.xxx\SQLEXPRESS
When I try to connect to the server using public ipadress
122.xxx.xxx.xxx\SQLSERVER
I get an error:
Error: 26 - Error Locating Server/Instance Specified) (.Net SqlClient
Data Provider)
I also have host name from dlinkddns, tried connecting with host name with same error.
Steps which I have tried:
Enabled remote connections.
Configured 1433 TCP port to be allowed in firewall. Disabled antivirus program. I tried disabling firewall with no success.
Enabled all protocols "TCP/IP', 'Named Pipes', 'Shared memory'
Under TCP/IP properties, changed 'IP All' 'TCP Port' to 1433. I tried enabling IP1 to public ipadress with port 1433 with no success.
I have dlink DIR 816 router, i dont see anything called port forwarding instead it has 'port triggering', i configured to allow port 1433 TCP and 1434 UDP.
I can ping both ipadress and hostname with success but the server would not connect.
I have tried everything to the best of my knowledge but nothing works, any inputs to setup my connection remotely will be of great help!
The error is pretty specific here.
error: 26 - Error Locating Server/Instance Specified (.Net SqlClient Data Provider)
You must understand one thing. Your local IP (192.168.0.xxx) is not visible from WWW. Only your Public IP or Global IP is. Once someone comes inside your network they will be able to ping your IP (192.168.0.xxx).
To make it work, you must have the SQL Server installed in a computer whose local IP is accessible from the internet. That means, it should be hosted in a Domain.
Connecting to SQL Server over the Internet
We can connect to SQL Server remotely over the internet if the Server has a static public IP address and port forwarding is configured on the router to allow remote connection requests through the router firewall.
In the router firewall settings, there is normally a games and application section, in there add SQL application and give the port range (1433 normally) and then direct the incoming connection by selecting the SQL Server device name on the network.
I fixed the issue by adding local ip into DMZ on my router. Everything works like a charm now.
I am working on a system whereby I can update a small database from several locations. I wish to host the database on my home computer and allow connections to be made to the database from two other locations through tcp/ip.
I have done the following thus far:
Enabled TCP/IP for SQLEXPRESS
Allowed port 1433 tcp on my firewall
Allowed port 1434 udp on my firewall
Enabled SQLEXPRESS server to allow remote connections
I was hoping to be able to connect to the database by opening sql management studio on the other pcs and using the following format [ExternalIP]\SQLEXPRESS but as of yet I have been unable to do so. I have looked at what my external IP might be and i am getting two different values:
86.XX.X.XXX
66.XXX.XX.XX
Should I be using either of these values with this format to connect from the other sql management studios when everything has been correctly configured? Are there any steps that I am missing?
Named instances of SQL Server don't listen by default on port 1433, but instead on a random port determined at each service startup. It's the function of the sql browser service to provide clients with actual ports of each running instance (and that's done using the fixed 1434 udp port).
The necesary steps would be to configure the server to use a fixed port, then setup the firewall and router to allow that port. When connecting, just use the external IP address with the port but not the instance name (as that would invoke the browser service, which is unneeded with fixed ports).
To resume, necesary steps would be these:
Enable remote connections on the server.
Setup users and permissions as needed (Windows authentication is a pain over internet, so SQL authentication is strongly recommended)
Enable TCP/IP for the instance.
Configure the server to use a fixed port for connections (1433 being the standard). Look here for instructions.
Restart the database server.
Give permissions on the firewall to allow the server executable incoming connections on your selected port. At this point other computers in the LAN should connect.
On your router forward the port you opened to your local machine private IP (note that in Windows you must configure your computer to use a fixed local IP instead of DHCP).
Test with a client over internet or just using your external IP.
Note that for the connection from the remote client, as server name you must use 86.XX.X.113,1433 (the port number is separated with a comma, optional if it's 1433). Notice that there is NO instance name, even if you installed it as SQLEXPRESS or whatever. This is due having a fixed listening port (like the default instance by default). That eliminates the need of the browser service and udp 1434, and the pain of a dynamic port forwarding.
You should also check that your ISP most likely will give you a dynamic external IP, so clients might be reconfigured when that changes. Or you can use some dynamic DNS service.
Config MSSQL Express 2014 connect remoto PC or PHP, etc..
View Video Tutorial Easy Config Server to MSSQL Express:
https://www.youtube.com/watch?v=5UkHYNwUtCo
Code Test Cliente Remote PHP:
$serverName = '192.168.1.64,49170'; //only the server name and ip MSSQL SERVER EXPRESS
$connectionInfo = array( "Database"=>"mydbName", "UID"=>"myUserId", "PWD"=>"myPass");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established";
}else{
echo "Connection could not be established.";
die( print_r( sqlsrv_errors(), true));
}