Cannot connect to AWS EC2 from visual studio (or anywhere actually) - visual-studio

I have an AWS server (MS SQL SERVER EXPRESS 2008 R2 with IIS), with an elastic IP of 54.214.8.111, security groups configured with HTTP, MS SQL and FTP, and I can connect to the remote virtual machine using the rdp file that amazon gives you in the console.
However when I try to connect via visual studio to test if the database is working, it gives me a "Login failed for user 'dbuser' error. I have a user called dbuser on my SQL Server (on the server side of course) with full access permissions etc. I also cannot connect to an ftp on the server, despite all guides and help doc. Something seems to be simply blocking my connection. I have tried the same thing on multiple computers.
Everything seems to be configured correctly except I suspect the server instance.
Can anyone help? PS I'm fairly new to web development, this is my first AWS EC2 server.
[UPDATE] I just tried to create a new instance in a different location, same error, maybe I don't know how to configure the SQL Server on the EC2?

I recently had the same connectivity issue to AWS/SQL Server, I finally have it resolved.
Connecting to SQL Server remotely on AWS involves 3 main factors:
AWS --> Windows Security --> SQL Server Settings/Security.
Connections can easily fail because each area has specific requirements. I'll go through the check-list:
AWS:
In AWS management console, go to Security Groups, click on the group that applies to your windows server, make sure MS SQL TCP port 1433 is open to your specific client IP. If not, you'll need to add it.
*UPDATE 5/10/22: In the inbound-security in AWS, if you enter 0.0.0.0 for source IP it will open that port publicly, you should not open the port to everyone. Only open this port to specific IP addresses and take additional security measures to protect it, allowing only authenticated users to access. Read up on security and how to configure to protect your SQL server.
Note the Public IP of your server
WINDOWS:
RDP to the Amazon Windows server, Start > Administrative Tools > Local Security Policy
Click Windows Firewall with Advanced Security, Windows Firewall Properties, Click the "Public Profile" tab, set Firewall State to "ON", Inbound to Block, Outbound to Allow (or block depending on your application). OK.
Expand the Windows Firewall (on the left Pane), R-Click the Inbound Rule, Click New Rule.
Click Port option, Next > , for TCP, enter 1433 Next >, Allow the connection, Next >, Next > , give it a name (SQL-PORT-ACCESS)
SQL-SERVER:
Login to SQL Server with SSMS (SQL Server Management Studio) using the default windows authentication.
On the left-pane, R-click the top server listing (with the database icon, the very first listing), and select "Properties"
Properties window, click Security on the left pane, choose the "SQL Server and Windows Auth"
Click Connections, check the "Allow Remote Connections" option ... Click OK.
Open the SQL Configuration Manager, Start > Programs > Microsoft SQL Server > Configuration Tools > SQL Server Configuration Manager
SQL Server Network Configuration (Expand), select Protocols for MSSQL, R-Click TCP , select Properties (TCP should be enabled)
Click IP Addresses tab, check that IP1 is enabled, Dynamic Ports is 0, TCP port is 1433
Scroll all the way down to IPAll section, Enter 0 in TCP Dynamic Ports, and 1433 in TCP Port. OK...
Back on the left pane, click, SQL Server Services, R-Click the SQL Server option, and select "Restart".
(NOTE: SQL Browser server does not impact connectivity, browser service only lists available servers, with your specific connection parms, no need to start or worry about the browser)
TESTING:
You don't have go to your remote client to test, start by trying to connect from the same SSMS window on the server. This reduces all the other things that can go wrong at first, if you can connect here, you have some confirmation that it works. If it doesn't work from your own server, the issues are related to Windows security and SQL security and setup.
Under the Object Explorer (SQL server Management Studio), click "Connect" > Database Engine...
In the Server name:, enter your PUBLIC IP, a comma, then 1433. Example, if your public IP is 54.4.4.4 , enter 54.4.4.4,1433,
Select the authentication as "SQL Server", enter the login user and password.
If you're using "sa", remember to change the password.
If your connection works locally, then you can try your remote client connection.
At this point you know your SQL server and user settings are correct.
Next, try using SSMS on another computer. If that fails, probably the firewall needs a 2nd look...
Good place to understand issues, is the SQL logs easily accessible from SSMS, on the left pane, expand Management, then SQL Server Logs, current log will list any problems.
So, those are all the parts involved -- miss one and you'll be frustrated, but start by reducing the pieces when testing.
I was able to connect to my database on AWS Windows Server/SQL Express from a Windows device...
Good Luck!

Related

TFS could not connect to database. Login field

I am getting the following error. Cannot solve.New to TFS. Please help.
TF246017: Team Foundation Server could not connect to the database. Verify that the server that is hosting the database is operational, and that network problems are not blocking communication with the server.--> login failed. Login from untrusted domain and cannot be used with windows authentication.
If you open SQL Server Manager on your TFS Server application tier using "runas" to open it under the same credentials that you expect TFS to use you should be able to diagnose more:
1) install SQL Server Manager on TFS AppTier
2) right-click on the SQL Server Manager icon and select 'run-as' ( you may need to hold alt)
3) enter the TFS Service (refer to TFS Installation Guide) credentials to open
4) try to connect to your SQL Server
If you cant connect verify that SQL is installed where you think it is and that there are no firewall issues for the standard SQL ports.

Cannot connect to AWS EC2 instance in Visual Studio

I have an AWS server (MS SQL SERVER EXPRESS 2008 R2 with IIS), with an elastic IP of 54.214.8.111, security groups configured with HTTP, MS SQL and FTP, and I can connect to the remote virtual machine using the rdp file that amazon gives you in the console.
However when I try to connect via visual studio to test if the database is working, it gives me a "Login failed for user 'dbuser' error. I have a user called dbuser on my SQL Server (on the server side of course) with full access permissions etc. I also cannot connect to an ftp on the server, despite all guides and help doc. Something seems to be simply blocking my connection. I have tried the same thing on multiple computers.
Everything seems to be configured correctly except I suspect the server instance.
Can anyone help? PS I'm fairly new to web development, this is my first AWS EC2 server.
[UPDATE] I just tried to create a new instance in a different location, same thing, maybe I don't know how to configure the SQL Server on the EC2?
It appears that by default EC2 SQL instances have SQL authentication disabled.
In SQL Management Studio, connect as the built in Administrator account, then go to
Server Properties>Security>
Under Server Authentication, change to "SQL Server and Windows Authentication Mode"
Restart SQL
Your local accounts should now work
Try running in elevated mode (right click Visual studio and run as Administrator), solved some issues I was having recently.

Can't login to SQL Azure Management

Actually i have following step by step from http://www.windowsazure.com/en-us/manage/services/sql-databases/getting-started-w-sql-databases/ to create database and etc.
But when i try to login using username and password which i have configured,message error appear " Failed to retrieve connection information. Try to login again. "
I have configure firewall before to allowed my public ip to access the database.
How to solve my problem ?
Thanks
Clear your cookies and browsing history and contact Microsoft support if this persists after some time (like an hour)
That is very interesting problem.
What about checking connection with Microsoft SQL Server (can be Express edition).
If you configured firewalls then you should be able to access Azure database via Microsoft SQL Server Management Studio from your system with no problems.
Alternatively you could check Visual Studio. But I am not sure if Visual Studio Express edition can connect to Azure databases (you might need some paid version).
If you still have some connectivity issue using SQL Management Studio then that would indicate some networking problems between your place and Azure data centre. In that case I would recommend spinning up another Azure database (for very short time) in different data centre, set up firewalls and see if that will work.
EDIT
Any way to configure Firewall for Azure ?
Firewall to database cannot be configured at a level of individual databases; it needs to be configured at a level of server.
In Windows Azure Management portal, go to Database tab and then select database server:
Once you in server dashboard, select configuration top tab. You can change DB Server firewall allowed IP addresses under Allowed IP Addresses
In the same section there is Current Client IP Address which tell you the current IP. That very handy when you work with VPN or change your network quite often.
Allow popups. Chrome was blocking this from me.

Unable to connect to SQL server while testing

I am working with Microsoft Visual studio Test, I do not know how to deal with the following error
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)
Make sure your database engine is configured to accept remote connections
Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration
Click on Surface Area Configuration for Services and Connections
Select the instance that is having a problem > Database Engine > Remote Connections
Enable local and remote connections
Restart instance
Check the SQL Server service account
If you are not using a domain account as a service account (for example if you are using NETWORK SERVICE), you may want to switch this first before proceeding
If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings in your ASweb P.NET application
Usually the format needed to specify the database server is machinename\instancename
Check your connection string as well
4.You may need to create an exception on the firewall for the SQL Server instance and port you are using
- Start > Run > Firewall.cpl
- Click on exceptions tab
- Add the sqlservr.exe (typically located in C:\Program Files (x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Binn), and port (default is 1433)
- Check your connection string as well
If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings
Check SQLBrowser; check that it is running. You may also need to create an exception in your firewall for SQLBrowser.
Check that you have connectivity to the SQL Server. Note what you are using to connect: machine name, domain name or IP address? Use this when checking connectivity. For example if you are using myserver
Start > Run > cmd
netstat -ano| findstr 1433
telnet myserver 1433
ping -a myserver
Check what ports are IP addresses are being returned.
Alternative:
If you still can’t get any connection, you may want to create a SQL account on the server, a corresponding SQL user on the database in question, and just use this username/password combo in your web application.
Credits for this answer goes to belle of sqlmusings.com

Connecting to database on web host in Visual Studio or Sql Server Management Studio

I have a web site developed locally with a local Sql Server database. I also have a web host that provides one Sql Server database for my site. Now I want to deploy the application, and I would like to be able to manage the remote database from the Server Explorer in Visual Studio. I have the connection string used in the application, which works fine for adding, say, a datasource to a control etc. But I don't know if there's any way to use it to connect the database inside the Server Explorer so that I can add tables etc. I have read that you're supposed to be able to this instead of using the Sql Server Management Studio, but I have'nt read anything about how to connect to the remote database in it.
What I have tried so far is this: I have selected Add database in Server Explorer. This brings up first a dialog where I choose Sql Server. And then I get a dialog where I can set Server name (which I tried using the ip address in the connection string below), and Authentication (where I chose Sql Server Authentication, with the user id and password from below). But when I test the connection it fails.
Here's the connection string, which works fine when used for datasources in the application (obviously with different user name and password):
Any help appreciated!
EDIT:
Well, I've done everything suggested by lewiguez below now, but it doesn't make any difference. I can't believe this should be so hard... I keep getting this error message in Sql Server Management Studio:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
Here's the process I follow for working with remote databases:
In VS 2008 under the Server
Explorer tab, right-click on "Data
Connections" and then click "Add
Connection"
Change the Data Source to
"Microsoft Sql Server"
Put in your fully-qualified
"Server Name" (be it IP Address, domain name, etc.), select "Sql Server
Authentication" and put in "User
Name" and "Password" for the database user
Select the database you want to connect to under "Select or enter a database name"
Hit "Test Connection" to test and then "OK" to accept
You should be able to interact with the database at this point by expanding the connection and then the "Tables" folder. For example, right-click on the Tables folder and you'll be presented with an "Add Table" option in the dialog. Right-clicking an existing table will bring up the "Open Table Definition" options where you can change any columns, etc.
If you're not getting to this point (and it sounds like you're not), I'd recommend checking your Sql Server connection from whatever machine you're using.
I generally do this by going into the Management Studio and connect with whatever credentials I'm trying to use. If they don't work, make sure they are, in fact, added as a Sql Server user and a database user (they have to be both).
Also, I would check in the Sql Server Surface Area Configuration Manager. You have to allow TCP connections and you have to be set up to allow Sql Server Authentication connections as well from remote hosts. If THAT'S all set up, but you still can't connect, I'd double-check to make sure your firewall is allowing Sql Server connections. The default port is 1433.
Also, if you can connect, but then can't write to anything, double-check your table permissions. Hope this helps!
I finally understood the problem: as I suspected the settings in my own installation was not the problem, but rather it was the settings on the Sql Server installation on my web host. And in fact I found a place in the control panel on my web host where I could set an exception to my ip address so that my ip would be granted access to the port 1433 for Sql Server, which is otherwise closed by default for security reasons.
I've had no luck finding any information about this at all on the internet, which I find strange. All the information I could find had to do with changing these settings on your own local installation of Sql Server. But I'm sure there are loads of people out there who like me use a web host for deploying their web site, and then that info doesn't seem to apply. (Perhaps apart from the TCP setting, which I think must be set, and there's detailed info about that here: http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/ )
Hope this helps someone else who like me uses a web host. Now everything works fine for me at least, both in Management Studio and in Visual Studio Server Explorer.

Resources