简体   繁体   English

django 连接远程 postgresql

[英]django connect remote postgresql

Trying to connect to a remote server, serving my posgresql尝试连接到远程服务器,为我的 posgresql 服务

My settings.py我的设置.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'mydatabase',
        'USER': 'mydatabaseuser',
        'PASSWORD': 'mypassword',
        'HOST': 'ubuntu@username.host.com',
        'PORT': '5432',
    }
}

Getting error:获取错误:

django.db.utils.OperationalError: could not translate host name "ubuntu@hostname.host.com" to address: Name or service not known

Where the hostname and host is of course not hostname and host, just using for this example.其中主机名和主机当然不是主机名和主机,只是用于这个例子。

For the host, you have to pass the ip address or the domain name of your postgresql host instance.对于主机,您必须传递 ip 地址或 postgresql 主机实例的域名。

'HOST': 'host.com'

or或者

'HOST': '<ip_address>'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM