Cannot remote connect to mssql server

Joined
Jul 12, 2007
Messages
417
Reaction score
24
The server is on a regular pc and im trying to connect with it from my pc using
mssql_connect("ip\SQLEXPRESS","user","pass");
I made a user in the security folder of db management tools and used for user that name with the pass I filled in for it. I granted remote connections in its properties but I cannot even connect to the ip
I did forward the port 1433 since that would be the standard port that mssql uses but it just doesnt work.
Im just testing from my pc if I can connect to it so I can connect trough the webhost I will buy as soon as I get it to work with a php file
This is the error I get:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: externalip\SQLEXPRESS in C:\server\web\mssql.php on line 2


When I log in to it like that on db management tools at the server pc with ip\SQLEXPRESS instead of computername\SQLEXPRESS it doesnt work either. I am sure the ip is correct as it goes to the website and other people can connect to it too trough that ip
 
The server is on a regular pc and im trying to connect with it from my pc using
mssql_connect("ip\SQLEXPRESS","user","pass");
I made a user in the security folder of db management tools and used for user that name with the pass I filled in for it. I granted remote connections in its properties but I cannot even connect to the ip
I did forward the port 1433 since that would be the standard port that mssql uses but it just doesnt work.
Im just testing from my pc if I can connect to it so I can connect trough the webhost I will buy as soon as I get it to work with a php file
This is the error I get:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: externalip\SQLEXPRESS in C:\server\web\mssql.php on line 2


When I log in to it like that on db management tools at the server pc with ip\SQLEXPRESS instead of computername\SQLEXPRESS it doesnt work either. I am sure the ip is correct as it goes to the website and other people can connect to it too trough that ip

In your configuration tools for MSSQL, you need to enable TCP/IP and set the default port to 1433. Otherwise, forwarding ports is useless as MSSQL by default is not set to bind on any ports for connections using IP addresses, only instance names.

This is a very common problem as, like I said, its not enabled by default.

These pics will help you. (god I love this screenshot program lol) Follow them pic by pic in steps, as I took them in that sense.

View gXoLQw.jpg on ScreenSnapr

View 8c3lUq.jpg on ScreenSnapr

View tpVFDw.jpg on ScreenSnapr

View bidsyN.jpg on ScreenSnapr

View aZ39B4.jpg on ScreenSnapr

View fAtxPY.jpg on ScreenSnapr

View a6lBb6.jpg on ScreenSnapr

View oLuSby.jpg on ScreenSnapr

To test it, install the telnet client and type this,

Code:
telnet 127.0.0.1 1433
You should get a blank screen. If you don't then your configuration isn't correct or a firewall is blocking it. Google to find out how to install telnet if you get an unrecognized command error.

Like my post if it helped.

I'd say thats one hell of a post for #6,500. :p

See if you can connect on the remote PC to the mysql at all , locally.

Other than that you need to grant your mysql external access before you can actually access it from remote computers.

How do I enable external access to MySQL Server? - Stack Overflow

google never hurts.
Reading never hurts either. He isn't working with MySQL here.
 
Don't ask me. Some guy here was like "Hey dude , don't just post blocks of code and show people where to copy and paste"...

So I guess I'll just google them the answers lmao.
Thats stupid. Thats what guides are; do this, put this here, go here and change this, and you're done.

People learn from that. If anyone says otherwise they can just stfu. lol

Anyways, we're off-topic. :p
 
In your configuration tools for MSSQL, you need to enable TCP/IP and set the default port to 1433. Otherwise, forwarding ports is useless as MSSQL by default is not set to bind on any ports for connections using IP addresses, only instance names.

This is a very common problem as, like I said, its not enabled by default.

These pics will help you. (god I love this screenshot program lol) Follow them pic by pic in steps, as I took them in that sense.

View gXoLQw.jpg on ScreenSnapr

View 8c3lUq.jpg on ScreenSnapr

View tpVFDw.jpg on ScreenSnapr

View bidsyN.jpg on ScreenSnapr

View aZ39B4.jpg on ScreenSnapr

View fAtxPY.jpg on ScreenSnapr

View a6lBb6.jpg on ScreenSnapr

View oLuSby.jpg on ScreenSnapr

To test it, install the telnet client and type this,

Code:
telnet 127.0.0.1 1433
You should get a blank screen. If you don't then your configuration isn't correct or a firewall is blocking it. Google to find out how to install telnet if you get an unrecognized command error.

Like my post if it helped.

I'd say thats one hell of a post for #6,500. :p


Reading never hurts either. He isn't working with MySQL here.

Thanks a lot ive been searching on where to set the ports but couldnt find it lol. And believe me I did a lot of research on google but nothing really worked. And this didnt either. Is externalip\SQLEXPRESS really the right format?
I cant login to mssql with that format on the pc itself either while I remember that it used to work earlier. Currently I log in with OWNER-HP\SQLEXPRESS
 
Doesnt work for me :/
Tried
mssql_connect('127.0.0.1,1433','name','pass');
mssql_connect('127.0.0.1','1433','name','pass');
mssql_connect('127.0.0.1:1433','name','pass');
mssql_connect('127.0.0.1','name','pass');

But with external ip ofcourse and neither of them worked

Edit:

Telnet gives a blank screen
 
Last edited:
If telnet gives a blank screen then MSSQL is accepting connections properly, so its your PHP config.

It can be either a comma or a colon for the port in the server host variable depending on your version of PHP. If its still not working then its probably your user/pass.

Turn on error reporting ( error_reporting(E_ALL); ) and see what its saying the issue is.
 
Thanks a lot even though it takes a while it connects now
I tried it on my PC instead of my laptop and used externalip,port and it works that way
But its reaaally slow is there a way to solve this?
It takes like 5 seconds at least to connect and my purpose is to connect from a webhost to that db and well if id do that it would take 5 seconds at least just to connect for everyone who visits the website
 
Definitely your connection or the way you are connecting.

Wireless will obviously be slower. Wire everything with cat 5e cable if possible, or any grade cabling will work as long as you're not wireless. Wire it up directly to the modem if it has a built in switch, if not then no more than one hop away.

Is it taking 5 seconds to connect locally or 5 seconds to connect externally? Regardless, it could also be a firewall slowing down your connections trying to filter everything. If not that, then your PHP script may be slow. Just trying to give you a bunch of stuff to test as I don't really know what your issue is.

Locally connecting to MSSQL should be instant.
 
Meh it seems that the host pc is connected wireless and the router is too far to connect with cable the owner says. Ill try to find a solution and if not Ill have to wait for the VPS. Thanks a lot anyway guys this helped a lot!
 
Back