postgres connection refused in ubuntu - linux

getting an error while connecting remotely and the error says something like
could not connect to server: Connection timed out (0x0000274C/10060) Is the server running on host x and accepting TCP/IP connections on port 5432?
please help me out

Open your terminal and write
service postgresql status
If it says it is not running than write
service postgresql start
If the service is already running then check the listening port of your postgresql service via
netstat -an | grep postgresql
and the result will show the port it is listening.And then you can connect your database with the command
psql -h localhost -p port_you_found -U postgres

Related

Logs to troubleshoot SSH tunneling errors

I am trying to troubleshoot connection errors when using SSH tunneling to connect to a rhel 8 EC2 server. Does anyone know of a log location on RHEL 8 that may contain more information when the connection is refused?
For reference I am using the following command (which works on all my other servers)
ssh -i -L 8745:IPOfServer:8443 ec2-user#IPOfServer
I get the error "open failed: connect failded: Connection refused
I can connect on 8080 but 8443 is refused even though the port is open and the application and firewalld are configured to listen on 8443 and 8080.
Thanks!!

Cant connect to postgresql server running in windows 10 virtual machine

I'm running a postgres server in a windows 10 virtual machine on my pop-os laptop. I'm trying to connect to it from my host OS (linux). In virtual box I created a port forwarding rule :
I also changed the listening port in the postgres configuration to equal '*'.
The error message I get trying to connect is this:
postgres#pop-os:/home/peyton$ psql -p 5432
psql: error: could not connect to server: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
I don't understand this very well so I could really use some help.
Thanks.
The problem is:
psql -p 5432
is saying connect to local socket on Linux machine. Per the error message:
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
You need to do something like:
psql -p 5432 -h 127.0.0.1

Odoo container : Database connection failure: could not connect to server: Connection refused (linking odoo with localhost postgres)

I'm trying to run the odoo docker container and linking it with my local (not container) postgresql.
I tried this command (as suggest here).
docker container run -p 8089:8069 -e HOST=127.0.0.1 -e USER=tux -e PASSWORD=tux --name odoo -t odoo
Ran it and got these errors :
Database connection failure: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Cannot assign requested address
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
I tried to open up the port 5432 with ufw but got the same erros. I also tried to change 127.0.0.1 to 0.0.0.0 but nothing.
Could you help me?
ps : the USER and PASSWORD are corrects, I use them when I run odoo instance in my local.
you might need to add the host network with a flag --network=host
WARNING: Published ports are discarded when using host network mode
that just means you cannot change the port bindings. thats as secure as your machine is.

Error remote access MongoDB on Ubuntu server

I have an Ubuntu 14.04 Linux server with MongoDB 3.2.4 running at Digital Ocean as a droplet (one-click Apps).
Pinging the server works (droplet is distroyed after posting this):
ping 198.199.125.101
I created database test and user:
db.createUser({"user": "test", "pwd": "test", "roles": ["dbOwner"]})
In mongod.conf I changed bindIp: 0.0.0.0 and restarted mongoDB
I disabled the firewall and reboot the server. Just for test, just to prove iptables is not the issue (don't do this on a regular server):
sudo ufw disable
The problem is I can't get remote access to the mongo Database
mongo 198.199.125.101:27021/test -u "test" -p "test"
Error message (connection refused):
MongoDB shell version: 3.2.0
connecting to: 198.199.125.101:27021/test
2016-05-11T22:05:35.876+0200 W NETWORK [thread1] Failed to connect to 198.199.125.101:27021, reason: errno:61 Connection refused
2016-05-11T22:05:35.879+0200 E QUERY [thread1] Error: couldn't connect to server 198.199.125.101:27021, connection attempt failed :
connect#src/mongo/shell/mongo.js:226:14
#(connect):1:6
exception: connect failed
First run netstat on the mongo machine to verify that the port 27021 is open. netstat -anp should do it.
Then do "telnet 127.0.0.1 27021" to make sure it is open.
Once you are sure the port is open, then use telnet 198.199.125.101 27021 to verify you can connect to the mongo machine on port 27021. If you can, then it has something to do with your app. If not then something is blocking the connection. Some firewall or something. Are you on aws?
As per netstat, can you try mongo 198.199.125.101:27017/test -u "test" -p "test"

Unable to connect to PostgreSQL server: could not connect to server: Permission denied

Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Permission denied Is the server running on host "10.0.1.201" and accepting TCP/IP connections on port 5432?
This is the error i am getting when trying to connect to remote database from linux based server
Though i am able to connect to it from localhost
Can anyone help me in this
One possible scenario/solution that worked for me (for the very same problem) is here:
service httpd stop
service postgresql stop
setsebool -P httpd_can_network_connect 1
service httpd start
service postgresql start
Here we're basically allowing HTTPD to connect to PostgreSQL over network by setting SELinux bool equals to 1 (true).
Check the listen_addresses setting in postgresql.conf. If it is set to localhost, then only loopback connections will be accepted, and remote connections will get a "connection refused" error. Set listen_addresses to "*" to enable listening on all interfaces.
In PostgreSQL you have to configure client authentication in pg_hba.conf on the remote server.
Read more about pg_hba.conf # http://developer.postgresql.org/pgdocs/postgres/auth-pg-hba-conf.html , otherwise you'll never connect to that server :).
Hope it will help,
Stefan

Resources