Configuring remote access for couchdb
By default, CouchDb is configured to be access only from a local port, i.e: you can connect to a couchdb instance as long as it is on the same host. Also, it is necessary that the HTTP request be made using the loopback IP address (127.0.0.1).
In case you want to be able to access a couchdb instance from an external machine, you need to make some changes to the couchdb configuration. Note that you would need to have superuser access in order to make changes to these files. Usually couchdb will have two configuration (ini) files in /etc/couchdb depending on your installation. Both these files (default.ini and local.ini) can be used to enable remote hosts to access couchdb. The configuration required for this is:
[httpd]
port = 5984
bind_address = 0.0.0.0
By default the configuration would be:
This means that the Http server is bound only to the loopback IP address, which is why we change it to 0.0.0.0 to make it bind to any IP address. If you don't need that, instead you want to allow it on a specific IP address only, you can do that too.
Whilst doing this, you must also understand the purpose of these two files. Default.ini is meant to contain all system wide settings that would want to have, while local.ini is to be used to override the system defaults.
Lastly, you need to stop and start your couchdb service after you make any changes to these ini files.
[httpd]
port = 5984
bind_address = 127.0.0.1
This means that the Http server is bound only to the loopback IP address, which is why we change it to 0.0.0.0 to make it bind to any IP address. If you don't need that, instead you want to allow it on a specific IP address only, you can do that too.
Whilst doing this, you must also understand the purpose of these two files. Default.ini is meant to contain all system wide settings that would want to have, while local.ini is to be used to override the system defaults.
Lastly, you need to stop and start your couchdb service after you make any changes to these ini files.
Still unable to connect. Can you help?
ReplyDeleteSorry for the late response. I haven't been around here for a while now. If it helps, this post is 4 years old, and couchdb might have changed since then. But, it would help if you give some more details as to what happens when you try to connect.
DeleteThanks.
Okay, I had done it some way. But thanks for the response. May I ask you if I have any more doubt or challenges?
DeleteHi Guys,
ReplyDeleteAm having the issue to make it remote access. Please help
If you are using an AWS EC2 instance then you have to add port 5984
ReplyDeleteThis is not working in my case.Any help for this. I have changed the bind_address in both the files to 0.0.0.0 but nothing happens. I am using an aws ec2 instance on which couchdb is installed. My email-id is mitultyagi45@gmail.com. Help!
ReplyDeleteHey it is done. Thanks for the post.Great one!.
ReplyDeletehello..
ReplyDeleteHow can I change this "bind_address" from my command line?
something like
"curl -X GET http://yahav:****@10.9.11.118:5984/_utils/#_config/main_config/chttpd"