【发布时间】:2016-09-06 18:31:22
【问题描述】:
我正在尝试像这样在本地连接到 Heroku postgre SQL 数据库,
from flask import Flask
import sys
import psycopg2
import urlparse
urlparse.uses_netloc.append("postgres")
url = urlparse.urlparse("postgres://url")
conn = psycopg2.connect(
database=url.path[1:],
user=url.username,
password=url.password,
host=url.hostname,
port=url.port
)
但经过长时间的停顿后,我收到以下错误,
psycopg2.OperationalError: could not connect to server: Connection timed out
Is the server running on host "URL" (IP) and accepting
TCP/IP connections on port 5432?
如何修复此错误并在本地连接到数据库?
【问题讨论】:
标签: python postgresql heroku