R
R
Roman Rakzin2016-08-07 12:51:01
PostgreSQL
Roman Rakzin, 2016-08-07 12:51:01

Can't connect to PostgreSql via GORM in Golang. What can be wrong?

What could be the reason that there is no access to the PostgreSQL database through GORM, but there is in PgAdmin. The settings are the same. Antivirus, firewall turned off. GORM pumped over a new one.

import(
        	//"github.com/jinzhu/gorm/dialects/postgres"
          "github.com/jinzhu/gorm"
          _ "github.com/lib/pq"
       )

The connection code
db, err := gorm.Open("postgres", "host=localhost:5432  user=postgres password=RomanRakzin dbname=MyDB  sslmode=disable")  
        if err != nil {
           log.Println("Ошибка подключения к базе данных......") 
        }

And I tried without specifying `host=localhost:5432` and just `host=localhost`.
There is a database, a user with such a password, too. Everything works in PgAdmin, but not here.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question