Daniel Daniel - 1 year ago 191
Python Question

ckan datapusher /api/3/action/resource_show (Caused by <class 'socket.error'>: [Errno 111] Connection refused) error

I'm trying install ckan 2.2.1 + pgsql 9.1 + solr 3.6 + rhel 6.6.

I set file store, and datastore plugin. I tried to use 'upload to datastore' menu in ckan web. then I got this error.

2016-09-23 23:16:54,655 INFO [ckan.lib.base] /dataset/datastore/resource_data/7a82b5c2-d68c-4bed-b5c6-fcc460011455 render time 0.363 seconds
Job "push_to_datastore (trigger: RunTriggerNow, run = True, next run at: None)" raised an exception
Traceback (most recent call last):
File "/usr/lib/ckan/default/lib/python2.7/site-packages/apscheduler/scheduler.py", line 512, in _run_job
retval = job.func(*job.args, **job.kwargs)
File "/usr/lib/ckan/default/src/ckan/datapusher/datapusher/jobs.py", line 300, in push_to_datastore
resource = get_resource(resource_id, ckan_url, api_key)
File "/usr/lib/ckan/default/src/ckan/datapusher/datapusher/jobs.py", line 250, in get_resource
'Authorization': api_key}
File "/usr/lib/ckan/default/lib/python2.7/site-packages/requests/api.py", line 87, in post
return request('post', url, data=data, **kwargs)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/requests/sessions.py", line 279, in request
resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/requests/sessions.py", line 374, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/requests/adapters.py", line 209, in send
raise ConnectionError(e)
ConnectionError: HTTPConnectionPool(host='default.ckan.com', port=80): Max retries exceeded with url: /api/3/action/resource_show (Caused by <class 'socket.error'>: [Errno 111] Connection refused)

ckan, solr is running well. datapusher with 8800 port is running.

$ curl localhost:8800
"help": "\n Get help at:\n http://ckan-service-provider.readthedocs.org/."

Am I missing something for my datapusher ?

I added my ini

cache_dir = /tmp/%(ckan.site_id)s/
beaker.session.key = ckan
beaker.session.secret = CkL+a+Nc6grW1jBM/Ts69mRsE
app_instance_uuid = {f41a65ac-4a33-44fe-bb03-af15b456978e}
who.config_file = %(here)s/who.ini
who.log_level = warning
who.log_file = %(cache_dir)s/who_log.ini
sqlalchemy.url = postgresql://ckan_default:PASS@localhost/ckan_default
ckan.datastore.write_url = postgresql://ckan_default:PASS@localhost/datastore_default
ckan.datastore.read_url = postgresql://datastore_default:PASS@localhost/datastore_default
ckan.datastore.default_fts_lang = english
ckan.datastore.default_fts_index_method = gist
ckan.site_url = http://ckan.daniel.com
ckan.auth.anon_create_dataset = false
ckan.auth.create_unowned_dataset = false
ckan.auth.create_dataset_if_not_in_organization = false
ckan.auth.user_create_groups = false
ckan.auth.user_create_organizations = false
ckan.auth.user_delete_groups = true
ckan.auth.user_delete_organizations = true
ckan.auth.create_user_via_api = false
ckan.auth.create_user_via_web = true
ckan.auth.roles_that_cascade_to_sub_groups = admin
ckan.site_id = default
solr_url =
ckan.plugins = stats text_view image_view recline_view datastore datapusher
ckan.views.default_views = image_view text_view recline_view
ckan.site_title = CKAN
ckan.site_logo = /base/images/ckan-logo.png
ckan.site_description =
ckan.favicon = /images/icons/ckan.ico
ckan.gravatar_default = identicon
ckan.preview.direct = png jpg gif csv
ckan.preview.loadable = html htm rdf+xml owl+xml xml n3 n-triples turtle plain atom csv tsv rss txt json
ckan.locale_default = en
ckan.locale_order = en pt_BR ja it cs_CZ ca es fr el sv sr sr@latin no sk fi ru de pl nl bg ko_KR hu sa sl lv
ckan.locales_offered =
ckan.locales_filtered_out = en_GB
ckan.feeds.authority_name =
ckan.feeds.date =
ckan.feeds.author_name =
ckan.feeds.author_link =
ckan.storage_path = /usr/lib/ckan/korea/src/ckan/filestore
ckan.max_resource_size = 10
ckan.max_image_size = 5
ckan.datapusher.formats = csv xls xlsx tsv application/csv application/vnd.ms-excel application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
ckan.datapusher.url = http://ckan.daniel.com:8800/
ckan.hide_activity_from_users = %(ckan.site_id)s

Answer Source

As you noticed in your comment, the problem is that the datapusher is trying to connect to the wrong port:

ConnectionError: HTTPConnectionPool(host='default.ckan.com', port=80): Max retries exceeded with url: /api/3/action/resource_show (Caused by : [Errno 111] Connection refused)

You already found a possible workaround: changing CKAN's port to 80.

As an alternative workaround, I found that adding the port (the same one configured with port in the [server:main] section) to ckan.site_url makes the datapusher use it instead of the default HTTP port (80). So, in your case it could be:

ckan.site_url = http://default.ckan.com:5000

Of course, this is just another possible workaround; the real solution would be to fix the datapusher so that it correctly reads the port from the configuration ...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download