Search code examples
urldnsip-addressckan

IP address in ckan.site_url not accepted by ckan db init


I am following the official installation procedure from package for CKAN 2.8 on a Ubuntu 16.04 VM without a domain (reachable via IP address).

I have have configured /etc/ckan/default/ckan.ini with the HTTP URL to the VM (ckan.site_url = http://192.168.56.101:80) but when I call ckan db init it returns the error ckan.site_url is not configured and it must have a value. I have also tried other variants for the URL, but none of them worked:

  • http://192.168.56.101
  • http://192.168.56.101:80
  • http://192.168.56.101/ (the docs say the trailing slash is not necessary, but you never know)
  • "http://192.168.56.101"

What am I doing wrong?

You can see below the content of /etc/ckan/default/ckan.ini and the output of ckan db init.

daniele@ckantest:~$ cat /etc/ckan/default/ckan.ini
solr_url = http://127.0.0.1:8983/solr
ckan.site_id = ckan-demo
ckan.site_url = http://192.168.56.101:80

daniele@ckantest:~$ sudo ckan db init
Traceback (most recent call last):
  File "/usr/bin/ckan", line 45, in <module>
    load_entry_point('PasteScript', 'console_scripts', 'paster')()
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
    invoke(command, command_name, options, args[1:])
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
    exit_code = runner.run(args)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 236, in run
    result = self.command()
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 357, in command
    self._load_config(cmd!='upgrade')
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 330, in _load_config
    self.site_user = load_config(self.options.config, load_site_user)
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 237, in load_config
    load_environment(conf.global_conf, conf.local_conf)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 116, in load_environment
    p.load_all()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 130, in load_all
    unload_all()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 183, in unload_all
    unload(*reversed(_PLUGINS))
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 211, in unload
    plugins_update()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 122, in plugins_update
    environment.update_config()
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 190, in update_config
    'ckan.site_url is not configured and it must have a value.'
RuntimeError: ckan.site_url is not configured and it must have a value. Please amend your .ini file.

EDIT:

I added a hostname rule linking ckan.demo to 192.168.56.101 and then edited ckan.ini using the hostname, but the error persist. Apparently the error is not caused by the IP but by something else.

You can see below the content of /etc/hosts, the content of /etc/ckan/default/ckan.ini and the output of ckan db init.

daniele@ckantest:~$ cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       ckantest

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

192.168.56.101 ckan.demo

daniele@ckantest:~$ nmap ckan.demo

Starting Nmap 7.01 ( https://nmap.org ) at 2020-05-05 14:26 CEST
Nmap scan report for ckan.demo (192.168.56.101)
Host is up (0.000044s latency).
Not shown: 996 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
8080/tcp open  http-proxy
8800/tcp open  sunwebadmin

Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds
daniele@ckantest:~$ cat /etc/ckan/default/ckan.ini
solr_url = http://127.0.0.1:8983/solr
ckan.site_id = ckan-demo
ckan.site_url = http://ckan.demo
daniele@ckantest:~$ sudo ckan db init
Traceback (most recent call last):
  File "/usr/bin/ckan", line 45, in <module>
    load_entry_point('PasteScript', 'console_scripts', 'paster')()
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
    invoke(command, command_name, options, args[1:])
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
    exit_code = runner.run(args)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 236, in run
    result = self.command()
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 357, in command
    self._load_config(cmd!='upgrade')
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 330, in _load_config
    self.site_user = load_config(self.options.config, load_site_user)
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 237, in load_config
    load_environment(conf.global_conf, conf.local_conf)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 116, in load_environment
    p.load_all()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 130, in load_all
    unload_all()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 183, in unload_all
    unload(*reversed(_PLUGINS))
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 211, in unload
    plugins_update()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 122, in plugins_update
    environment.update_config()
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 190, in update_config
    'ckan.site_url is not configured and it must have a value.'
RuntimeError: ckan.site_url is not configured and it must have a value. Please amend your .ini file.

Solution

  • is it possible that you forgot to provide the location to the configuration file?

    ckan -c /etc/ckan/default/ckan.ini db init
    

    cheers, Florian