[Solved] Error running query: Unknown MySQL server host / But test connection pass

Issue Summary

I can’t execute Query, but “Connection Testing” is pass and it can load list of table.

It respond with Error running query: Unknown MySQL server host 'frappe' (0).
frappe is a container which has MySQL server running in it.


Technical details:

  • Redash Version: I’ve tried both redash/redash:7.0.0.b17489 and redash/redash:7.0.0.b18042
  • Browser/OS: [Opera, Chrome, Firefox] / Windows 10
  • How did you install Redash: I use docker-compose on Windows 10 (This is Dev server not Production server)

docker-compose.yml
11-1-14_py3_devcontainer_default network is network which frappe container use.

	version: '2'

	x-redash-service: &redash-service
	  image: redash/redash:7.0.0.b18042
	  depends_on:
		- postgres
		- redis
	  env_file: ./env
	  restart: always

	services:
	  server:
		<<: *redash-service
		command: server
		ports:
		  - "5000:5000"
		environment:
		  REDASH_WEB_WORKERS: 4
		networks:
		  - default
		  - 11-1-14_py3_devcontainer_default

	  scheduler:
		<<: *redash-service
		command: scheduler
		environment:
		  QUEUES: "celery"
		  WORKERS_COUNT: 1
	  scheduled_worker:
		<<: *redash-service
		command: worker
		environment:
		  QUEUES: "scheduled_queries,schemas"
		  WORKERS_COUNT: 1
	  adhoc_worker:
		<<: *redash-service
		command: worker
		environment:
		  QUEUES: "queries"
		  WORKERS_COUNT: 2

	  redis:
		image: redis:5.0-alpine
		restart: always
		networks:
		  - default
		  - 11-1-14_py3_devcontainer_default

	  postgres:
		image: postgres:9.5-alpine
		env_file: ./env
		restart: always
		networks:
		  - default
		  - 11-1-14_py3_devcontainer_default

	  nginx:
		image: redash/nginx:latest
		ports:
		  - "80:80"
		depends_on:
		  - server
		links:
		  - server:redash
		restart: always
		networks:
		  - default
		  - 11-1-14_py3_devcontainer_default


	networks:
	  11-1-14_py3_devcontainer_default:
		external: true

.env

	PYTHONUNBUFFERED=0
	REDASH_LOG_LEVEL=INFO
	REDASH_REDIS_URL=redis://redis:6379/0
	REDASH_DATABASE_URL=postgresql://postgres:12345@postgres/postgres

	POSTGRES_PASSWORD=12345

Error log from adhoc_worker container

	[2019-07-31 16:15:56,665][PID:1][INFO][MainProcess] Received task: redash.tasks.execute_query[1dce61d3-356c-45ba-9e58-7603476063a6]
	[2019-07-31 16:15:56,667][PID:110][INFO][ForkPoolWorker-2] task_name=redash.tasks.execute_query task_id=1dce61d3-356c-45ba-9e58-7603476063a6 task=execute_query state=load_ds ds_id=1
	[2019-07-31 16:15:56,672][PID:110][INFO][ForkPoolWorker-2] task_name=redash.tasks.execute_query task_id=1dce61d3-356c-45ba-9e58-7603476063a6 task=execute_query state=executing_query query_hash=d42cbeb354900af9a4ec3e24a377a25f type=mysql ds_id=1  task_id=1dce61d3-356c-45ba-9e58-7603476063a6 queue=queries query_id=1 username=p@pipech.com
	[2019-07-31 16:16:11,689][PID:110][INFO][ForkPoolWorker-2] task_name=redash.tasks.execute_query task_id=1dce61d3-356c-45ba-9e58-7603476063a6 task=execute_query query_hash=d42cbeb354900af9a4ec3e24a377a25f data_length=None error=[Unknown MySQL server host 'frappe' (0)]
	[2019-07-31 16:16:11,690][PID:110][ERROR][ForkPoolWorker-2] Task redash.tasks.execute_query[1dce61d3-356c-45ba-9e58-7603476063a6] raised unexpected: QueryExecutionError("Unknown MySQL server host 'frappe' (0)",)
	Traceback (most recent call last):
	  File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 382, in trace_task
		R = retval = fun(*args, **kwargs)
	  File "/app/redash/worker.py", line 64, in __call__
		return TaskBase.__call__(self, *args, **kwargs)
	  File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 641, in __protected_call__
		return self.run(*args, **kwargs)
	  File "/app/redash/tasks/queries.py", line 390, in execute_query
		scheduled_query).run()
	  File "/app/redash/tasks/queries.py", line 333, in run
		raise result
	QueryExecutionError: Unknown MySQL server host 'frappe' (0)

Any help would be really appreciated. :grinning:

You connected the server container to the other network, but didn’t do it for the worker containers. You can add it to the shared definition (x-redash-service:) to reduce copy-paste.

It works!

Thank you very much for your support. :grinning::grinning::grinning: