You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Shabu Khan <hi...@gmail.com> on 2021/04/10 13:01:40 UTC

Error connecting to cassandra through php/browser

Hello:
When I try this from the command line it works:

[root@localhost cassandra]# cqlsh -u testuser -p Welcome123! -k testapp
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.10 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
testuser@cqlsh:testapp> 

But through the browser it fails with this error with the same credentials/keyspace:
Could not connect to the specified Cassandra keyspace: Underlying connection error: Connect error 'permission denied'

I am on CentOS7. The exact same configs works through the browser on Ubuntu 18.04.

Any thoughts?




Re: Error connecting to cassandra through php/browser

Posted by Bowen Song <bo...@bso.ng>.
Temporarily disable SELinux (or set it to permissive mode) for 
troubleshooting is fine, but once you know SELinux is the cause, you 
should consider change the policies (often via setsebool or audit2allow) 
to allow the connection. Blindly disable SELinux does solve the issue, 
but it isn't a good security practice.

On 11/04/2021 06:35, Shabu Khan wrote:
> Thank you Bowen. Much appreciated.
>
> You were right. I disabled the selinux and I got past that error/page.
>
> ## To temporarily disable selinux on centos 7
> $ sudo setenforce 0
>
> ## To permanently disable, set SELINUX=disabled in /etc/selinux/config
>
> -Shabu
>
> On Sun, Apr 11, 2021 at 1:26 AM Bowen Song <bo...@bso.ng> wrote:
>> What do you mean "through the browser"? Is it a php page that runs on
>> something like Apache/Nginx? If that's the case, and the same code and
>> the same setup works on Ubuntu 18 but not CentOS 7, I would recommend
>> you to have a look at the SELinux logs.
>>
>> On 10/04/2021 14:01, Shabu Khan wrote:
>>> Hello:
>>> When I try this from the command line it works:
>>>
>>> [root@localhost cassandra]# cqlsh -u testuser -p Welcome123! -k testapp
>>> Connected to Test Cluster at 127.0.0.1:9042.
>>> [cqlsh 5.0.1 | Cassandra 3.11.10 | CQL spec 3.4.4 | Native protocol v4]
>>> Use HELP for help.
>>> testuser@cqlsh:testapp>
>>>
>>> But through the browser it fails with this error with the same credentials/keyspace:
>>> Could not connect to the specified Cassandra keyspace: Underlying connection error: Connect error 'permission denied'
>>>
>>> I am on CentOS7. The exact same configs works through the browser on Ubuntu 18.04.
>>>
>>> Any thoughts?
>>>
>>>
>>>

Re: Error connecting to cassandra through php/browser

Posted by Shabu Khan <hi...@gmail.com>.
Thank you Bowen. Much appreciated.

You were right. I disabled the selinux and I got past that error/page.

## To temporarily disable selinux on centos 7
$ sudo setenforce 0

## To permanently disable, set SELINUX=disabled in /etc/selinux/config

-Shabu

On Sun, Apr 11, 2021 at 1:26 AM Bowen Song <bo...@bso.ng> wrote:
>
> What do you mean "through the browser"? Is it a php page that runs on
> something like Apache/Nginx? If that's the case, and the same code and
> the same setup works on Ubuntu 18 but not CentOS 7, I would recommend
> you to have a look at the SELinux logs.
>
> On 10/04/2021 14:01, Shabu Khan wrote:
> > Hello:
> > When I try this from the command line it works:
> >
> > [root@localhost cassandra]# cqlsh -u testuser -p Welcome123! -k testapp
> > Connected to Test Cluster at 127.0.0.1:9042.
> > [cqlsh 5.0.1 | Cassandra 3.11.10 | CQL spec 3.4.4 | Native protocol v4]
> > Use HELP for help.
> > testuser@cqlsh:testapp>
> >
> > But through the browser it fails with this error with the same credentials/keyspace:
> > Could not connect to the specified Cassandra keyspace: Underlying connection error: Connect error 'permission denied'
> >
> > I am on CentOS7. The exact same configs works through the browser on Ubuntu 18.04.
> >
> > Any thoughts?
> >
> >
> >

Re: Error connecting to cassandra through php/browser

Posted by Bowen Song <bo...@bso.ng>.
What do you mean "through the browser"? Is it a php page that runs on 
something like Apache/Nginx? If that's the case, and the same code and 
the same setup works on Ubuntu 18 but not CentOS 7, I would recommend 
you to have a look at the SELinux logs.

On 10/04/2021 14:01, Shabu Khan wrote:
> Hello:
> When I try this from the command line it works:
>
> [root@localhost cassandra]# cqlsh -u testuser -p Welcome123! -k testapp
> Connected to Test Cluster at 127.0.0.1:9042.
> [cqlsh 5.0.1 | Cassandra 3.11.10 | CQL spec 3.4.4 | Native protocol v4]
> Use HELP for help.
> testuser@cqlsh:testapp>
>
> But through the browser it fails with this error with the same credentials/keyspace:
> Could not connect to the specified Cassandra keyspace: Underlying connection error: Connect error 'permission denied'
>
> I am on CentOS7. The exact same configs works through the browser on Ubuntu 18.04.
>
> Any thoughts?
>
>
>