PostgreSQLは動いているのですか?
Like!
pythonからPostgreSQLに接続したいのですが、エラーが出て接続ができません。
解決方法をご教授していただきたいです。
ould not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
connection = psycopg2.connect(
^^^^^^^^^^^^^^^^^
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
import psycopg2
path = '127.0.0.1'
port = '5432'
dbname = ''
user = ''
password = ''
conText = 'host={} port={} dbname={} user={} password={}'
conText = conText.format(path,port,dbname, user, password)
connection = psycopg2.connect(conText)
cur = connection.cursor()
postgresql.conf
pg_hba.conf
の編集
PostgreSQLは動いているのですか?
@owari758
Questionerpsql -h 127.0.0.1 -p 5432 -U user ? -d dbname?
ログインはできるのでしょうか?
dbname = ''
user = ''
@owari758
Questioner@owari758
Questioner@owari758
Questionerpsycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
psycopg2でエラーが起きたよ。
(PostgreSQL)Serverに繋げられなかったよ。
(PostgreSQL)Serverは127.0.0.1で起動してる?また5432ポートで稼働してる?
127.0.0.1はpythonスクリプトを実行したマシンと同じマシンです。
PostgreSQL Serverを同じマシンで起動しているでしょうか。
5432ポートで起動しているでしょうか(postgresql.confをportで検索)
受付アドレスは正しいでしょうか
(postgresql.confをlistenで検索)
pythonスクリプトからではなくpsqlコマンドからは繋げられるでしょうか。
といった切り分けを試してみてください
@owari758
Questioner