【问题标题】:Cannot connect to localhost from redash无法从 redash 连接到 localhost
【发布时间】:2019-02-02 07:29:37
【问题描述】:

我正在尝试从 Redash 连接到本地 postgres。 (来自 redash.io 和 http://0.0.0.0:5000/)但无法连接到它。我可以连接本地主机的其他工具,但从 Redash 我得到错误:

 Connection Test Failed:
 could not connect to server: Connection refused Is the server running 
 on host "localhost" (::1) and accepting TCP/IP connections on port 
 5432? could not connect to server: Connection refused Is the server 
 running on host "localhost" (127.0.0.1) and accepting TCP/IP 
 connections on port 5432?

任何想法可能是什么问题?我正在为我的本地 Redash 使用 docker,这可能会导致问题,但我也从 redash.io 收到相同的错误。

这是我的 docker-compose 文件:

# This configuration file is for **development** setup. For production, refer to
# docker-compose.production.yml.
version: '2'
services:
  server:
    build: .
    command: dev_server
    depends_on:
      - postgres
      - redis
    ports:
      - "5000:5000"
    volumes:
      - ".:/app"
    environment:
      PYTHONUNBUFFERED: 0
      REDASH_LOG_LEVEL: "INFO"
      REDASH_REDIS_URL: "redis://redis:6379/0"
      REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
  worker:
    build: .
    command: scheduler
    volumes_from:
      - server
    depends_on:
      - server
    environment:
      PYTHONUNBUFFERED: 0
      REDASH_LOG_LEVEL: "INFO"
      REDASH_REDIS_URL: "redis://redis:6379/0"
      REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
      QUEUES: "queries,scheduled_queries,celery"
      WORKERS_COUNT: 2
  redis:
    image: redis:3.0-alpine
    restart: unless-stopped
  postgres:
    image: postgres:9.5.6-alpine
    # The following turns the DB into less durable, but gains significant performance improvements for the tests run (x3
    # improvement on my personal machine). We should consider moving this into a dedicated Docker Compose configuration for
    # tests.
    command: "postgres -c fsync=off -c full_page_writes=off -c synchronous_commit=OFF"
    restart: unless-stopped

您可以在this repo 中查看整个项目。 谢谢。

【问题讨论】:

  • postgres 是否在 docker 上运行?您能否展示如何创建 docker 容器?发送 dockerfiles 或 docker-compose 并展示如何运行它。
  • gist.github.com/deepak365/3316270abce892370414bee232f31551 我按照这里的说明进行操作。我在本地有一个单独的 postgres,不在 docker 中(尽管 redash 也创建了一些 postgres 图像)
  • images: REPOSITORY TAG IMAGE ID CREATED SIZE redash/redash latest bec561ff0cc0 3 个月前 1.07GB redis 3.0-alpine 856249f48b0c 14 个月前 12.6MB postgres 9.5.6-alpine cc38b642ca58 15 个月前 36. nginx 最新 76abf32984e9 2 年前 134MB
  • 一共很难看到4张图片:redash/redash, redis, docker, redash/nginx
  • 如果你在 docker 容器中运行 redash,并且你的 postgres 数据库在你的计算机中。 Redash 无法使用 'localhost' 连接 postgres,因为 'localhost' 是连接到 docker 容器,而不是连接到您的计算机。您应该指向本地 IP 而不是 localhost,或者为 postgresql 使用 docker 容器。看看这个类似的问题:stackoverflow.com/questions/51849404/…

标签: postgresql redash


【解决方案1】:

localhost 更改为host.docker.internal 让它发挥作用。

【讨论】:

  • 这只是返回无效的主机名。
猜你喜欢
  • 1970-01-01
  • 2016-11-05
  • 2020-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-01
  • 2012-01-08
相关资源
最近更新 更多