Connection refused to PostgreSQL server - database

I am currently setting up a postreSQL server on my Windows computer.
I want to create my first database, but couldn't create the createdb function due to a password authetification failed. Thus I found the following question on this website:
How to configure postgresql for the first time?
However, I think I forgot the ; at the end of :
ALTER USER postgres with encrypted password 'xxxxxxx';
And now, when I try to launch psql, I have the following errors:
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Active code page: 1252
psql: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
Press any key to continue . . .
Any idea of what I could do to solve the problem?
Do you think it is really the missing semi column that caused the problem?
Do you have any tutorial on how to setup a postgreSQL database on Windows? All the one I found until now were for Linux only.

The error you're getting appears to be from Postgres not currently running, rather than an authentication error as you're presumed. The PSQL client or whatever PG client you're using is attempting to establish a connection on the default port but nothing is there.
If Postgres isn't currently running, try finding it (Via CTRL-Alt-Delete). If it's running, try terminating it and starting it up again. Hopefully that fixes the problem... Otherwise your port 5432 might be blocked for some reason.
If all fails, I am still skeptical the parentheses could cause this error because it's not an authentication error. Try to reinstall Postgres with a clean install.

Related

SQL Server Hosted on Lightsail Unavailable remotely

I have a SQL Server - Developer edition - hosted on an Ubuntu 20.04 Lightsail instance in AWS. I have a static IP configured, and I have my ports opened up on 1041 to allow traffic to the server. I am able to SSH into the server remotely, and I can see that the 1041 port is open - however, any time I try to connect to the server through SSMS, I'm unable to actually connect to it, with the 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: TC Provider, error: 0 - The wait operation timed out.) (Microsoft SQL Server, Error: 258)
I'm able to run commands using /opt/mssql-tools/bin/sqlcmd -S localhost,[myPort] -U [myUsr] -P [myPwd] -Q "[myQuery]", so I know the server is up and running, and responsive.
I've validated that the server is listening on the SQL Server port by calling netstat -tunlp, and seeing that the port is in the LISTEN state.
I've validated that I have no additional Firewall running, so the only thing that should be blocking is the Lightsail Networking. I decided to go for broke, and opened up the server to all TCP traffic - which still got me nowhere.
I've checked to see that remote connections are allowed (they are) - but I have a feeling this is where my issue lies. I read that the command to allow remote connections is EXEC sp_configure 'remote access', 1 ; - I ran this, and rebooted and still nothing. Then I found out that that command isn't necessarily related to allowing remote connections TO the server, and it instead allows remote connections FROM the server.
Is there any other options/tools that I'm missing that I can use to allow remote connections to the SQL Server?
Edit 1 - Updating ipaddress in config
On the advice of #AlwaysLearning, I updated my mssql.conf file to explicitly list 0.0.0.0 as the ipaddress of the sql server.
When I did this, I restarted the mssql server, and it now crashes constantly. I removed the 0.0.0.0 address, but it looks like that was able to force mssql to start up listening under 0.0.0.0?
However, it is still unable to connect remotely. I noticed that when I run tcpdump -nn -i any port 1041, I DO see connections to it, but I DON'T see my attempts from my external connection to it. It looks like I'm listening correctly now, but I don't actually get any traffic to the server?

PgAdmin- Postgres: could not connect to server: Connection refused (0x0000274D/10061)

Hi i want to use PostgreSQL for a school project and whenever i open the server in Pg Admin i got the same issue
when i first open Pg Admin i enter the password that i entered in the installation and when i click to server(1) it requires password for user "postgres" i use the same password but it tells me:
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 1500? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 1500?
i don't know what does it really mean .. cause i'm new to databases and servers
i reinstall all postgres & Pg admin : same issue
i restart the server in services-postgres.. : same issue
I'm using PostgreSQL-12 and Pg Admin-4 in Windows-10
image
please help !!
and thank you !
On windows:
click on windows
search for services
scroll down to postgresql
right-click on it and select properties
click on the startup type dropdown button and select automatic
then click start
this will automatically run your postgresql
I am facing the same problem and as I edited the port to 5432 it worked. In my case, Postgres was running on 5433 and I changed it to 5432
Pretty sure the problem is due to this:
... accepting TCP/IP connections on port 1500
Postgres runs by default on port 5432. Try changing the port setting to 5432.
For me the issue is due to not starting a server, so you should start the server, one way to do it is to cd to postgresql bin and start it with pg_ctl, here is an example:
cd "C:\Program Files\PostgreSQL\14\bin"
pg_ctl -D "C:\Program Files\PostgreSQL\14\data" start

Unable to connect to SQL Server via JDBC on Linux

I am able to connect to my SQL Server instance via the following JDBC connection on a Windows machine:
jdbc:sqlserver://<my_server>;databaseName=<my_db>;integratedSecurity=true;authenticationScheme=JavaKerberos;username=<my_user>;password=<my_pwd>
However, when the same connection string is invoked on a Linux machine, I get the following error stack:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host <my_server>, port 1433 has failed. Error: "Connection timed out: no further information.. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
I have tried altering the JDBC string to remove the integratedSecurity=true, according to this forum, but I am encountering the same error message.
Is the error message related to authentication or networking?
I am able to SSH into the Linux machine and successfully ping <my_server>
I would first try if I can reach 'my_server' on the standard port from your Linux client, e.g.
telnet my_server 1433
as MS Sql Server is listening on port 1433, MySQL is listening on 3306.
If this is fine, use the basic URL as duffymo mentioned above. Probably add username and password:
jdbc:sqlserver://myserver:1433;databaseName=my_db;user=my_user;password=my_password

Connection to Postgresql database failing

I'm trying to connect to my localhost Postgresql database and I'm getting an error:
Connection to database... failed
No other message provided.
I'm using using pgAdmin3 connecting to Postgresql 10.1
I've been connecting to this database using the same user (and password) and another user via my app successfully all the while but it just failed to connect to the database now. No users seems to be able to connect to the database
Edit: after further checks I noticed Postgresql is not listening on the port 5432.
I've checked the postgresql.conf file and it looks fine
listen_addresses = '*', port = 5432
I'm kind of new to Postgresql. Sorry if it's something obvious I'm missing out. Still looking for how to start postgresql or make it listen on the port.

sql whitelisting not working when connected to a university intranet

I have been having troubles to establish database connection using the MS SQL Management Studio. It was working fine when I was using a local internet service provider. However, when I began to use the university internet, I am not able to connect to the db, although I sql-whitelist the ip. I have no ideas how to manage this issue. I have to connect to the db to manage it, but I am receiving "A network-related or instance-specific error occurred while establishing a connection to SQL Server..." Do you have any idea? Is this something that my hosting company should figure out?
Thanks!
There is a reasonably good chance you are being blocked by a firewall at the university. They probably block/allow based on IP. Universities should not allow all IP's in the University net to have access by default.
You may have had a firewall exception for the old address. You can check if port is blocked by using the telnet command from any windows client command line.
telnet 127.0.0.1 1433 -- substitute your sql server ip address or name
telnet 127.0.0.1 22334 -- no reason for the this port to be open
This is what a blocked port looks like
C:\>telnet localhost 22334
Connecting To localhost...Could not open connection to the host, on port 22334:
Connect failed
C:\>
If 1433 is open and associate with ms-sql you get a different behavior (although it is pretty odd) -- you may have to close the command prompt or kill the telnet process. In any case, this confirms the port is open or closed. If port is open and you can't connect, you have a connection string problem or something obscure.

Resources