Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL is not enabled on the server

Tags:

go

People also ask

Could not connect PQ SSL is not enabled on the server?

pq: SSL is not enabled on the server By default, sslmode is set to required with lib/pq , so you need to actually specify another setting to fix this. Update your connection string to include sslmode=disable and you should be back in action.


You should establish DB connection without SSL encryption, like that:

db, err := sql.Open("postgres", "user=test password=test dbname=test sslmode=disable") 

If your data source name is a url, you will do it like this:

db, err := sql.Open("postgres", "postgres://username:password@localhost/db_name?sslmode=disable")

sslmode is just added to the db url like a query parameter.


Notice, please:

This even occurs, if you have indicated a sslmode=disable, but have empty other param. For example dbname=

For example, connection string:

user=test password=test dbname=sslmode=disable will also issue this error, because dbname is empty.


To establish a connection without SSL, try

postgres://username:password@host:5432/database?sslmode=disable

This is how I got it working:

db, err := sql.Open("postgres", "postgres://{user}:{password}@{hostname}:{port}/{database-name}?sslmode=disable")