Help Connecting Ubuntu Server 14.04 VM/postgres to postgreSQL workbench on localhost?

I'm new to SQL and am trying to configure and Ubuntu Server 14.04 VM to connect to SQL Workbench x64 on the localhost. Below are my settings for the Virtual machine's port forwarding and the error I receive when When trying to connect.

Oracle Virtual box Port forwarding Settings:

FTP = 127.0.0.1:2020 -> 10.0.2.15:20
HTTP = 127.0.0.1:8080 -> 10.0.2.15:80
SQL (Not Sure) = 127.0.0.1:5432 -> 10.0.2.15:5432
SQL (Service) = 127.0.0.1:1156 -> 15.0.2.15:1156
SSH (Data Transfer) = 127.0.0.1:2222 -> 10.0.2.15:22

Error When Connecting to postgres from MySQL workbench:

Failed to Connect to MySQL at 127.0.0.1:1156 with user dj
Lost connection to MySQL server at 'reading initial communication packet', system error: 0

If I understand what I've done, I've forwarded the port that postgres runs on inside the virtual machine to the same port on the local host. Also, i've used ufw to allow port 1156.

So i'm unsure why this isn't working, Any help would be much appreciated!

3

1 Answer

You have to edit the file under

sudo vim /etc/postgresql/9.3/main/pg_hba.conf

And Press SHIFT+G Now change md5 to trust in the below line

host all all 127.0.0.1/32 md5

to

host all all 127.0.0.1/32 trust

If you need to listen from any IP address we have to edit the file under

sudo vim /etc/postgresql/9.3/main/postgresql.conf

And search for localhost and uncomment the below line

listen_addresses = 'localhost'

And change * localhost to *

listen_addresses = '*'

If you need login postgres User you have to do the below settings

Edit the file

sudo vim /etc/postgresql/9.3/main/pg_hba.conf

Press SHIFT + G to reach the bottom of the file

And change the md5 to trust

local all postgres md5

to

local all postgres trust

Then save the changes and exit by wq!

Then restart the server using

sudo service postgresql restart

Note:> Here i'am using PostgreSQL version 9.3, In you environment it may change according to you choose the version.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like