Bruce Mathers
Bruce Mathers

Reputation: 681

Can't connect to postgres on ubuntu

I have a ubuntu 20 on dreamcompute (which is cloud computing).

I create a user and a database. Here is the list of database and users (for some reason, I can't see database under a matt username).

I went into: nano /etc/postgresql/13/main/postgresql.conf & nano /etc/postgresql/13/main/pg_hba.conf and did the whole '*' and '0.0.0.0/0'

postgres=# \l
                              List of databases
   Name    |  Owner   | Encoding | Collate |  Ctype  |   Access privileges
-----------+----------+----------+---------+---------+-----------------------
 postgres  | postgres | UTF8     | C.UTF-8 | C.UTF-8 |
 strapi    | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =Tc/postgres         +
           |          |          |         |         | postgres=CTc/postgres+
           |          |          |         |         | hossein=CTc/postgres
 template0 | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
 template1 | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
(4 rows)

as you can see you can't see Superuser and database strapi under the matt username.

                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 matt      |                                                            | {}
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 ubuntu    |                                                            | {}

I'm using my dream compute's ip address as my host and use my database and user and password but get error message: connection attempt time out.

enter image description here

Could someone please give me a pointer on why this is happening? I have been working onthis for 2 weeks now and I can't get it to work.

Upvotes: 0

Views: 265

Answers (2)

Bruce Mathers
Bruce Mathers

Reputation: 681

as ex4 mentioned above I needed to reachout to the company that I was renting my cloud computer from but I still could not connect to the database.

The way I went around it is that you can ssh into your database and then connect to your database as a localhost since you are ssh into your cloud computer.

In DBeaver you have a ssh tab and you can connect and then you got back to your postgres tab and fill the localhost, user, database name, and user password area and simply click connect.

Sadly this took weeks to come to this :/

Upvotes: 0

ex4
ex4

Reputation: 2428

Error message is connection time out. That usually means that the port is blocked by a firewall. Check your cloud provider firewall settings and iptablesin your Linux box in case you have installed it.

If there was problem with permissions, the error message would be something else.

Upvotes: 1

Related Questions