Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I'm not exactly sure, how I can connect to a database I have on heroku through my local server created by WebMatrix. I have code to connect to the database work if I run the php script when my application is hosted on heroku. The line below fails:

$dbconn = pg_connect("host=someEC2Instance.com port=5432 dbname=xxxxxxx user=xxxxxxxx password=xxxxxxxxxx sslmode=require options='--client_encoding=UTF8'") or die('Could not connect: ' . pg_last_error());

I want to work with the database hosted on heroku, does anybody know what's wrong here?

share|improve this question

Normaly databases are not configured for "external" access. I dont know the hoster heroku very well but: I would say you can't access the database "from external" with your webserver.

Could you post the complete error message?

You could echo the "pg_last_error".. I bet it says something like "connection refused" or "connection timed out".

To access the database you should host the WebApplication on heroku OR install the database local on your pc.

Greetings.

share|improve this answer
    
not the case with Heroku - they allow direct database connections. – John Beynon Dec 17 '13 at 12:03
    
No line after pg_connect execute, so I can't output pg_last_error – Matan Vardi Dec 18 '13 at 2:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.