WebFaction
Community site: login faq
0
1

Getting the following error when my PHP page attempts to access my Postgres database.

webXXX.webfaction.com: Unable to connect to PostgreSQL server: received invalid response to SSL negotiation: 4

I have read the Accessing DB page, and it appears that SSL is set on for the Postgres database. Any idea how I can make this work? I tried using the SQL SET command to disable SSL but was unsuccessful. I'm fine with either disabling SSL or copying the cert to a place my PHP page can use it. Thank you,

-Adam

asked 21 May '11, 15:03

AdamHe
3113
accept rate: 0%

edited 21 May '11, 15:04


What URL are you using to connect to the DB with? Please post the code, minus real login info so we can see how you are connecting to the DB exactly.

permanent link

answered 21 May '11, 17:01

johns
5.4k312
accept rate: 23%

Sure, here you go:

function GetGlobalConnectionOptions()
{
return array(
'server' => 'webXXX.webfaction.com',
'port' => '3306',
'username' => 'UserID',
'password' => 'SuperSekritPW',
'database' => 'dbnamehere'
);
}

Any ideas?

permanent link

answered 21 May '11, 19:26

AdamHe
3113
accept rate: 0%

Change server to 127.0.0.1 or localhost, that domain will try an external connection.

(21 May '11, 19:52) johns

Tried both localhost and 127.0.0.1 and got this:

Could not connect to 127.0.0.1: Unable to connect to PostgreSQL server: received invalid response to SSL negotiation: 4

(22 May '11, 17:25) AdamHe

For what it's worth, I'm using the free trial version of PHP Generator to create the PHP pages:

http://www.sqlmaestro.com/products/postgresql/phpgenerator/

If there is a better solution to use that is out there, please let me know. Thank you!

-Adam

(22 May '11, 17:50) AdamHe

Can you login to the database with phppgadmin and the username and password you are using (replace XX with the server number)?

https://webXX.webfaction.com/static/phpPgAdmin/index.php

Is there more to that code? You should not need SSL for localhost connections.

(22 May '11, 18:21) johns

A better solution depends on what you are trying to build. If you just want a simple site with content management you should pick a project like WordPress or Joomla. If you want to build something from scratch and have complete control you should not use a generator of any kind but learn a programming language and pick a web-framework, I use Django and Python for all of my personal work.

(22 May '11, 18:24) johns

I'm FIXED! Thank you so much JohnS - here's what the problems were:

  1. Port number was wrong: I had 3306 from a misreading of the Accessing DB page I linked in my first post. Should have been 5432.

  2. Username was wrong - I had it as 'postgres', and it should have been the schema name.

Using the link you gave me above gave me the info I needed (username & port) to make this work - thank you so much!

-Adam

(22 May '11, 18:32) AdamHe

Glad to hear it is working :D I totally skipped the port, sorry about that.

(22 May '11, 18:43) johns
showing 5 of 7 show 2 more comments

Why are you using port 3306? The default port for PostgreSQL is 5432. I just looked at my scripts, and I'm connecting fine without actually specify a port for pg_pconnect()

permanent link

answered 10 Nov '11, 15:00

Arunas
1527
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×109
×108
×93
×22

question asked: 21 May '11, 15:03

question was seen: 19,687 times

last updated: 10 Nov '11, 15:00

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM