External database not connected

External database not connected

by Aditya Dubay -
Number of replies: 14

Hi,

I am using Moodle 3.1.1

When I try to connect external database I got below warning.

Warning: mssql_connect(): Unable to connect to server: 103.35.120.150:1433 in /home/courseai/public_html/certificate/lib/adodb/drivers/adodb-mssql.inc.php on line 616
103.35.120.150:1433: Connection error to server '103.35.120.150:1433' with user 'servicesaisectcsc'
Cannot connect the database.

 

adodb-mssql.inc.php line 616 is:

$this->_connectionID = mssql_connect($argHostname,$argUsername,$argPassword,$newconnect);

 

Please help me in this.

Thanks in advance.

Attachment database-error.png
Average of ratings: -
In reply to Aditya Dubay

Re: External database not connected

by William Lu -
Picture of Particularly helpful Moodlers

Moving to Installing and Upgrading forum...

In reply to William Lu

Re: External database not connected

by Aditya Dubay -

Hi William Lu,

I dont understand why this is issue of "Installing and upgrading" not "Database" as "External database" is part of auth and enrol plugins.

Anyways I need help and if it comes here I dont mind smile

Thanks

In reply to Aditya Dubay

Re: External database not connected

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You didn't actually say it was external database enrolment... I think we assumed you where using this database for Moodle.

In reply to Aditya Dubay

Re: External database not connected

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The obvious question is are your hostname, username and password correct? Don't just say 'yes', check it wink

If it worked before, what changed (even if it seems unrelated)?

In reply to Howard Miller

Re: External database not connected

by Aditya Dubay -

Hi Howard Miller,

I checked thrice and details are right smile and this is first time I configure this smile

What to do now ?

In reply to Aditya Dubay

Re: External database not connected

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I don't know anything about mssql but is there a client you can run on the same server as your Moodle site? If so, try that... can you connect. 

Also, ask the database admin to check his/her logs to see why your login is failing (or even if they can see you at all)

Is there a firewall between you and the database? Is it correctly configured. Again, logs should help (ok, I have a thing about checking logs!!)

In reply to Howard Miller

Re: External database not connected

by Aditya Dubay -

Hi Howard,

Thanks for reply.

I try to explain more.

I have a moodle instance on dedicated server which is linux server.

I have a website based on .net and MSSQL on sharing server where we register users for paid courses.

Now the point is once user register there can come to moodle instance and take a quiz for which he was registered.

So what I found is there is "External database" option in authentication and enrolment, so I feel I can do what I want with this. But I am not able to connect external database it gives above error smile

 

In reply to Aditya Dubay

Re: External database not connected

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yes - as I said. You really need to properly test the connectivity. It's not especially straightforward but a quick Google turns up things like this... http://richbs.org/post/43142767072/connecting-to-microsoft-sql-server-from-unix

Either...

- you don't have connectivity to the server (port is blocked, IP is blocked etc.)
- your username / password is wrong
- the hostname isn't correct for the server
- the sql server is rejecting your connection

You have to systematically exclude all of those. It must be one of them. Don't just say "it's right" you have to *prove* it wink

In reply to Howard Miller

Re: External database not connected

by Aditya Dubay -

Hi Howard,

 

I checked so many times and details are right as I am able to connect mssql database from other methods.

Ports/ips are not blocked on both servers.

Details are right.

SQL server is not receiving connection from moodle so there is no matter of accepting/rejecting.

I checked so many times before writing all these here.

 

In reply to Aditya Dubay

Re: External database not connected

by Olumuyiwa Taiwo -
Picture of Plugin developers

Earlier, you said:

   > SQL server is not receiving connection from moodle so there is no matter of accepting/rejecting

Is SELinux enabled on your Moodle server by any chance and blocking outbound connections? If so you'll need to either disable it, or configure it to allow outbound connections.

Other things you may want to check:

  • IPtables (or Firewalld, or some other firewall application, depending on your Linux distribution & version) is not blocking outgoing connections from your Moodle server.
  • The relevant MS SQL Server instance on the Windows box is actually listening on port 1433. I'm not a MS SQL Server expert, but it seems instances of MS SQL Server are able to listen on ports other than 1433 - see http://stackoverflow.com/questions/1518823/how-to-find-the-port-for-ms-sql-server-2008 for example.


In reply to Olumuyiwa Taiwo

Re: External database not connected

by Salman Zaidi -

I have same problem. In my case external db is MSSQL Server and i have tested the setting in moodle external db view thats perfectly connected. I tested my auth with test db and test table having less user records and it worked well. BUT when i connected with actual table having large amount of users and run sync_users.php file  its takes lot of time first (as i set appropriate max execution time settings in php.ini file) then it gives this error Warning: mssql_connect(): Unable to connect to server /lib/adodb/drivers/adodb-mssql.inc.php on line 616. My moodle intance and external db both are on windows OS.

Have you resolved this problem? Or any one can please tell me about the resolution of this issue.

In reply to Aditya Dubay

Re: External database not connected

by kamesh veerachamy -

Are you already installed mssql extension in your server.

http://php.net/manual/en/mssql.installation.php whether you didn't installed the mssql extension,please go ahead.

In reply to kamesh veerachamy

Re: External database not connected

by Aditya Dubay -

Hi kamesh veerachamy,

It is installed otherwise it says MSSQL extension not installed.

 

In reply to Aditya Dubay

Re: External database not connected

by Salman Zaidi -
Hi Aditya

I have same problem. In my case external db is MSSQL Server and i have tested the setting in moodle external db view thats perfectly connected. I tested my auth with test db and test table having less user records and it worked well. BUT when i connected with actual table having large amount of users and run sync_users.php file  its takes lot of time first (as i set appropriate max execution time settings in php.ini file) then it gives this error Warning: mssql_connect(): Unable to connect to server /lib/adodb/drivers/adodb-mssql.inc.php on line 616. My moodle intance and external db both are on windows OS.

Have you resolved this problem? Or any one can please tell me about the resolution of this issue.