Why N1QL query not working on 8093 port and 8091 port?

Hi, Im working on N1QL. But unfortunately N1QL query not working on 8093 query port.

Can i do anything for working with N1QL on 8093 port?
I tried with 8091 port but here im getting 404 error. i used following line.

http://myaddress.com:8091/query/service?statement=SELECT%20*%20from%20default

How can i run successful N1QL query on either port number 8091 or 8093?

Yes, @isha will help you with this.

@geraldss Thank you, i will look forward to @isha response.

Hi Srinadh,

From our previous discussions I summarize that you can send requests to 8091 but not to the n1ql query node. You seemed to have all the 3 services enabled.

I have a couple of questions :

  1. What version of Couchbase are you using
  2. Can you see a query tab on the UI. If so that is the query workbench. Could you please try to query using that and see if it works for you. Run the following query there

select * from system:keyspaces;

  1. If this works then query is working. You need to always issue queries against the query service. Hence run the following curl command :

Try the following curl command (after replacing my host to your hostname or ip):
curl -v http://myhost:8093/query/service -d ‘statement=select 1’

Could you post both the outputs here. We can go forward from there.

Thanks
Isha

Hi @isha Im using 4.1.0-5005 Enterprise Edition (build-5005) Here is the image.

There is no Query tab.

Can you try this and post the output here ?
Also could you use the shell (cbq) and try ?

What os are you running on ?

Thanks
Isha

Hi here is the result.

i dont know about shell (cbq)

What OS are you running on ?

CBQ location for different os (On the machine that runs couchbase) :

For Centos /opt/couchbase/bin
For Windows mostly Program Files\Couchbase\Server\bin
For Mac /Applications/Couchbase\ Server.app/Contents/Resources/couchbase-core/bin/

cd into that dir and run cbq by executing

./cbq

See if you can execute a query here.
Sample query : select * from system:keyspaces;

Hey im sorry i forget you to mention about os. its ubuntu Centos.

hey im using docker. so i need some time to do it.

@isha hi, im back with result of cbq here is the result.

So it looks like you can connect to the query service. Cbq is a command line tool that allows you to run N1QL queries. Since you are running on docker, there can be a couple of issues when connecting from outside (not your docker instance, which as we see works, from running cbq above)

  1. you havent exposed the ports when bringing up the docker instance
  2. If you access it from another machine, you need an ip rewrite rule.

@arungupta will be able to help with the docker connection issue.

Thanks
Isha

1 Like

@isha thank you. i will look forward to @arungupta

Detailed instructions on running a Couchbase Docker container are at:

https://docs.docker.com/engine/examples/couchbase/

How did you start your Couchbase Docker container?

Did you expose port 8093?

Thanks @arungupta, i’m using docker by following lines. https://github.com/couchbaselabs/Couchbase-by-Example/tree/master/07-deploy-digital-ocean

im really worrying why im not able to access query port 8093. its very important for me to access N1QL. please help me on it.

That is a dated document, please don’t use that.

As I said earlier, the latest instructions are at:

https://docs.docker.com/engine/examples/couchbase/

In your case, you need to make sure the query port is exposed as well. So instead of starting the server as:

docker run -d -p 8091:8091 couchbase/server

Start it as:

docker run -d -p 8091-8093:8091-8093 -p 11210:11210 couchbase/server

http://blog.couchbase.com/2015/december/couchbase-4.1-docker-container also provides exactly how you can connect to a Docker container using CBQ.

Let me know if that works.

1 Like

@arungupta, thanks i will check it and i let you know.

@arungupta Perfect now its working. i was used out dated coucbase/server now 8092 and 8093 ports are available. Thanks for your glad help @arungupta, @isha and @geraldss

2 Likes

@arungupta I have another instance running in other server. Now it is live. Again 8093 port is not working. i was follwed out dated tutorial to run docker. So is there any way to turn on 8093 port on existing instace, without any data lose and issues.

Hi @itssrinadh,

I think that this is really a docker question, not a couchbase question, so you may want to ask on StackOverflow or the Docker forums. But I’ll take a shot at it:

If you followed the outdated instructions, then it’s likely you did something like this:

docker run -d -p 8091:8091 couchbase/server

Which means that only port 8091 is exposed from the docker host. I’m assuming that you’re trying to execute queries on port 8093 from outside of the docker host. So, what you need to do is open up port 8093.

It doesn’t look like docker has a way for you to expose ports while the container is running, so you will likely have to stop the container and start it again . I am not a docker expert like @arungupta, so there may be some other way that I don’t know about. Here are some similar discussions I found: http://stackoverflow.com/questions/19897743/exposing-a-port-on-a-live-docker-container and https://forums.docker.com/t/how-to-expose-port-on-running-container/3252

I would suggest that you make a backup of the data before you do anything, just in case something goes wrong. Make sure to follow the up to date instructions to expose the correct ports (see https://hub.docker.com/_/couchbase/ for instance):

docker run -d --name db -p 8091-8094:8091-8094 -p 11210:11210 couchbase