Postgres: Unable to connect to domain socket - macos

Running psql gets me this:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I installed Postgres 9.3.3 using Homebrew.
which psql gives /usr/local/bin/psql
This seems to be a common issue. I'm terribly sorry to ask again, but I've gone through at least a dozen Q&As here and can't resolve the issue. A few posts I've gone through include:
Why am I getting a could not connect to server error for postgres in Mac OS Lion?
Postgres cannot connect to server on Unix domain socket 5432
Can not connect to local PostgreSQL
Many thanks,
Justin

Have you modified postgresql.conf to accept incoming TCP/IP connections? You should uncomment the listen_addresses parameter and set it to an appropriate subnet mask. Then in pg_hba.conf you have to add a line to enable connections to databases over TCP/IP. Both configuration files are in your data directory (don't know where that is on OSX).

Related

How do you write an odbc.ini file with configured ssh tunelling?

I'm on m1 mac, with tableau 2021.4, and as a result I'm forced to used the iodbc.org SDK. The app doesn't work or register drivers meant for the m1 mac so I've used the intel x86_64 mysql odbc driver. I'm not asking tableau support for reasons.
The mysql db I need to connect to is on a server I can't connect to directly (behind a vpc) and an ssh tunneling works sometimes within tableau. This link is the closest one to my problem. tableau_support. Regardless, The connection keeps dropping and I'm guessing it's due to the odbc.ini file being configured incorrectly.
Ive been referring to this as it's the closest thing to help me figure this out: iodbc but I'm at my wits end.
My odbc.ini file:
[connection_name]
Driver = /usr/local/mysql-connector-odbc-8.0.20-macos10.15-x86-64bit/lib/libmyodbc8w.so
Username = db_username
Database = db_name
Port = 3306
Server = db_name.xyz.us-east-1.rds.amazonaws.com
Hostname = ec2-##-##-##-##.compute-1.amazonaws.com
How can I write a mysql odbc.ini file with the correct parameters to set up an ssh tunnel or to work with an ssh tunnel?
As an addition, the db itself is not on localhost, it has its own different endpoint and I need to use a pem file to gain access to the server the db is hosted on.
...
What about creating SSH-Tunnel, similar to this?
ssh myaccount#db_server -L 9002:localhost:3306
Then connect to port 9002 on m1-localhost this will be forwarded to db_server.
If port 3306 isn't used on your m1, you can use it to simplify:
ssh myaccount#db_server -L 3306:localhost:3306 -N
Details: man ssh
Or simplified: http://lifesim.de/lex/ssh.html

Windows - jboss on docker, connection refused to local oracle database

I have Jboss running in a docker container. On jboss I have defined a connection to the xa-datasource database as the ip address of my computer and not localhost because I work in Windows 10. Despite the correct ip and port to the database (oracle) I keep getting the connection refused error. I run jboss with the command
docker run -d -p 8080:8080 -p 9990:9990 myjboss
Can anyone help me, or do I need any additional settings in my docker. I will add that I also test alpine and in the container (exec) I can ping my ip address.
Thanks a lot for all the answers. I would like to add that I tested all other solutions contained in similar questions, but unfortunately I did not get the expected results.
If you can ping your host IP, but you can’t connect to the database, granted that the DB is running and the listener is up...
I’d advise you to check the Windows Firewall settings.
Maybe try disabling it to check if you can actually connect to the database, if so, add an Inbound Rule to the firewall to allow connections on port 1521 (or whatever port your listener is running on)
I solved this problem by using not ip/localhost but host.docker.internal as described here -> https://docs.docker.com/docker-for-windows/networking/

How can I connect to a remote mongodb server using the mongo shell?

Trying to connect to a remote MongoDB server I get: socket operation timed out.
and the firewall log also doesn't mention any attempted connection.
I have the Mongodb running on a remote Windows 2012 vm.
I used --bind_ip 0.0.0.0 and added the firewall rules from the docs.
ping´ing from either client/server works and so does the vnc.
And I'm able to connect from the server using either localhost or the ip
Im new to networking and thought I slowly understand, but apparently thats not the case!
Is there anything else I did not consider?
Try this in your terminal
mongo -u <USER> -p <PASSWORD> <HOST>:<PORT>/<DB> --authenticationDatabase <AUTH_DB>

SQL*Plus connection SetUp: ORA-12154 Error

Sorry for the noob question but I am new to Oracle SQL software.
I've been trying to create a connection to my database student (created on SQL Developer), but got quite confusing since I'm using a client-computer which will connect to server.
Below are the info about the connection:
Connection Name: LARGER123
Username: LARGER123
Hostname: uxkg265.admin.plent
Port: 1520
SID: ticp5076
Client-computer username: r5678
When I open the SQL Plus prompt, I tried several combinations on the username in order to establish the connection, but got the same error ORA-12154 Error.
I though that it could be the way I was setting the things on username field, so I followed the instructions from Oracle's website:
https://docs.oracle.com/database/121/ADMQS/GUID-1A15D322-B3AC-426A-86A1-EB7590930687.htm#ADMQS045
Basically it tells to "build" the username structure in that way:
nick#"dbhost.example.com/orcl.example.com"
Where: "nick" is the user; "dbhost.example.com" is the host; and "orcl.example.com" is the database.
So, following the example I put my username in that way and got errors:
LARGER123#"uxkg265.admin.plent/student"
I tried different ways, including the Port and SID but got no success.
Do you have a better idea of what's my mistake?
Are you quite certain somebody is listening where you are trying to connect. I would suggest you start by testing with telnet.
You say your server has the domain name “uxkg265.admin.plent”
nslookup uxkg265.admin.plent
I just checked my IP address and found:
$ nslookup $(hostname)
Server: xxx.xxx.xxx.xxx
Address: xxx.xxx.xxx.xx##53
Name: mydomain.myorg.com
Address: 192.168.56.1
I just tried to connect to my oracle instance and got:
$ telnet 192.168.56.1 1521
Trying 192.168.56.1...
Connected to 192.168.56.1
Escape character is '^]'.
^]
telnet> quit
Connection closed.
If I try to the wrong port, I get:
$ telnet 192.168.56.1 1522
Trying 192.168.56.1...
telnet: connect to address 192.168.56.1: Connection refused
I was able to connect with:
sqlplus myoracle/testpass#192.168.56.1:1521/UPGR
where UPGR is the service name.
I was also able to connect with:
sqlplus myoracle/testpass#"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.1)(PORT=1521))(CONNECT_DATA=(SID=UPGR)))"
With UPGR as the SID.
I had some trouble initially because my version of Oracle Linux had iptables enabled and that was keeping me from connecting using sqlplus. As soon as I disabled this protection, I was able to use Oracle.
sudo service iptables stop
sudo chkconfig iptables off
(Keep in mind that iptables serves a purpose. For my test system running on my PC in VirtualBox, turning it off is fine. For other systems, maybe not.)
ORA-12154 is TNS:could not resolve the connect identifier specified, but you likely aren't using TNS to resolve the connect identifier: have you edited the tnsnames.ora file on the client machine and created an entry for the SID you're trying to connect to? Probably not.
Instead of selecting SID, select "Service name" and put the Oracle SID there. With the "Basic" connection type, that should use the host/port and service name explicitly to build the connection rather than relying on TNS to look up (resolve) the SID.

Postgresql refusing connection to server

I have been trying to connect to my postgresql 9.3 server but I keep getting this error.
Server doesn't listen
The server doesn't accept connections: the connection library reports
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting TCP/IP
connections on port 5433? 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?
I have tried connecting through pgadmin3 and the command line.
psql.exe -h localhost -U postgres
This command also gives the same error.
I am on a windows machine. I have tried creating a separate server also with the same result.
I have no idea whats happening. Please help.
Thanks
As the error clearly tells or asks actually, Is the server running on host "localhost"?
So the chances are, the Postgres server is not running on your machine.
You can start the service(the layman way) by going to services and starting the service.
Here is how you do it:
Open Run Window by Winkey + R
Type services.msc
Search Postgres service based on the version installed.
Click stop, start or restart the service option.
Start the server with postgres -D ['data folder']
As in docs:
http://www.postgresql.org/docs/9.1/static/server-start.html
So in my Windows postgres installation from the bin folder:
postgres.exe -D ..\data
where data is in the postgresql installation folder
I had the same issue like Venkatesh had. But in my case I had installed pgadmin in version 9. But also installed version 12 at the same time.
When I now uninstalled version 9, the port was already set in the config of version 12 and not given free.
So my solution was to change the port of version 12 in the postgresql.conf file. Or even simplier, change the port in the server creation from 5432 to 5433. Now you are able to create a server again.
I got this same error. This happened when I uninstall and re-install postgress, for some reason after second-time installation, pgadmin tries to connect to the server on port 5433 whereas the server is running on 5432.
Rightclick server properties and change the port to 5432 and try to connect again. It should work now.
Your server running on port 5432 but in the properties, the port is set to 5433.
You must go to pgAdmin, click on database version, ex: PostgresSQL 10 and edit properties.
A new window appears and you need to change the port to 5432 [this is default port].
Hope this helps.

Resources