SQL Server thinks I'm logging in with a machine account from flyway, but I'm not - flyway

Trying to use command line flyway to connect to SQL Server. Ports 1433 and 1434 are open on the firewall and tCPIP set up to use them on the SQLServer Config Manager.
From the flyway conf file:
flyway.url=jdbc:sqlserver:////<mymachineName>;databaseName=AdventureWorks2012
flyway.user=<username>
flyway.password=<password>
When I run
.\flyway info
I get something like:
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (ERROR: :String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Unable to obtain connection from database (jdbc:sqlserver:////<myMachineName>;databaseName=AdventureWorks2012) for user '<username>': The TCP/IP connection to the host //<myMachineName>, port 1433 has failed. Error: "//<myMachineName>. Verify the connection properties. Make
sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL State : 08S01
Error Code : 0
Message : The TCP/IP connection to the host //<myMachineName>, port 1433 has failed. Error: "//<myMachineName>. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make
sure that TCP connections to the port are not blocked by a firewall.".
I also get a weird error in the sql error log:
Source Logon
Message
Login failed for user '<domain_Name:MachineName$'. Reason: Could not find a login matching the name provided. [CLIENT: <local machine>]
Basically appears to be saying I'm trying to log in with a machine account.
Any help welcome.

Too many slashed in the url? Should be only
jdbc:sqlserver://<mymachineName>
^^
Only two slashes here.

Related

Can't connect to my SQL Server Express from an ASP.NET web app

I'm working on a tool that uses an SQL Server as a database.
First I was using Visual Studio's localdb, then I was using an Azure SQL Server, both of which worked just fine.
I now tried to host my own SQL Server Express, but I can't seem to connect to it. It's hosted in an Azure VM, I have restarted it, enabled TCP and I have opened Port 1433 in Azure.
I have tried both connecting remotely, running the web-app on my local computer and connecting to tcp:{IP}\InstanceName, as well as running the app on an IIS Server on my VM using .\InstanceName in the connection string (although I still get told to check if the server is set up correctly to handle TCP ? )
Connecting locally on the VM, using Microsoft SQL Server Management Studio works though, so I suspect the connection string in my web.config must be wrong ...
It looks like this:
<connectionStrings>
<add name="defaultConnection"
connectionString="Server=tcp:12.345.678.910\InstanceName,1433;Initial Catalog=master;Persist Security Info=False;User ID=sa;Password={mypassword};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
providerName="System.Data.SqlClient" />
</connectionStrings>
The error message I get is:
Server Error in '/application-name' Application. The remote computer refused the network connection.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The remote computer refused the network connection
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: [Win32Exception (0x80004005): The remote computer refused
the network connection]
[SqlException (0x80131904): 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: TCP Provider, error: 0 - The remote computer refused the network connection.)]
(and more but it doesn't seem important - will post if necessary or helpful)
Any idea what I'm doing wrong?
Found the solution on my own:
It's not enough to enable TCP in the Server Configuration Manager, you also have to SQL Server Network Configuration > Protocols for X > TCP > Properties > IP Adresses and set TCP Port to 1433 under IPAll.
SQL Server Express doesn't allow remote connections - by default.
You need to explicitly enable remote connections - easiest way is to use SQL Server Management Studio, connect to it, and then in "Object Explorer" right-click on the server icon, and pick "Properties".
In the dialog that shows up, make sure to tick the "Allow remote connections to this server" checkbox:

AspNet MVC template issue

I'm having some trouble with the asp.net "register/login system" that comes ready with the AspNet MVC template.
It worked great for me up until recently that I started receiving 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)
I tried running old versions of the code that used to work and they failed as well, I don't know what could have caused it.
Thanks ahead!
Eran
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
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
more info at: http://www.sqlmusings.com/2009/03/11/resolving-a-network-related-or-instance-specific-error-occurred-while-establishing-a-connection-to-sql-server/
This problem occur usually when you publish your project. This happens when there is problem in connection string and make sure you SQL server as well as SQL server browser are running.

Asp.net - Microsoft SQL Server outgoing connections

I was wondering if there is a way to see if a server blocks outgoing connections. I am trying to connect to an external database from a client's server.
This is the error I get:
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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
Edit:
I forgot to say I only have access to the plesk control panel. That's why I was asking if there is a way with asp.net.
When you say "server", do you mean the asp.net server, or the SQL server? And are both machines on the same network? Is this hosted?
Sql Server:
They can remove the OPENROWSET functionality, so you can't connect to remote servers, regardless
I doubt they are giving you access to linked servers in a hosted env
ASP.Net
You can try to connect to the other server via a regular connection, and see if that works.
Download a tracert component, and use that to try to trace from your server to the remote one.
If it dies somewhere inside your network, then that is your answer (it is blocked)
If it works, the outbound is open. Doesn't mean 1433 is open though.
If it dies after, not blocked, but maybe the remote is blocking icmp echo
Remember to try to tracert to somewhere else that you know works
It will be hard to tell what is killing the connection on 1433, if you can get to the server using other means. Could be the firewall, their fw, etc.
The trusty telnet method:
telnet theserver 1433
If this times out, the server is not listening. If the screen blanks and you can type something, the server is listening and no firewall is blocking the connection.
In Vista and Windows 7, you have to install telnet as a Windows component from Control Panel -> Programs and Features.

Getting a sql connection error when trying to login

I have a login page that works in my local development environment. When I push the site onto the web server, i am getting this error when trying to login from the asp.net login control.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I cannot figure out why it does not work on the server. Do I need to add anything or change something in the web.config?
This support article may help. It may also be a firewall issue or an authentication issue on the new setup (but the error message makes that less likely).
For resolving error 26 in sql server you need to do the following steps.
At Server System
1. Under surface area configuration manager-Open up remote connections.
2. Add into firewall 1433 and 1434 port no as n exception.
3. Open port 1433 on router for WAN access.
4. Add client machine ip address as an exception to your antivirus or allow LAN settings in antivirus.
5. Now try to check if both client and server are connected to each other.
for this type "ping IP address of remote system" at run and if reply is obtained then do same for server machine.
If reply is obtained from both machines.
Open Sql server and try to connect to remote machine which allow remote connections using its ip address. U will surely get connected to server machine
See this video
Check to make sure TCP/IP is enabled on the SQL Server. For whatever reason, named pipes and TCP/IP is off by default. Also make sure you are trying to connect to the correct instance (maybe you are using ./SQLEXPRESS locally and on the server SQL is installed on the default instance). Lastly, make sure the database you are trying to connect to exists on the server.

How to send mail from ASP.NET with IIS6 SMTP in a dedicated server?

I'm trying to configure a dedicated server that runs ASP.NET to send mail through the local IIS SMTP server but mail is getting stuck in the Queue folder and doesn't get delivered.
I'm using this code in an .aspx page to test:
<%# Page Language="C#" AutoEventWireup="true" %>
<% new System.Net.Mail.SmtpClient("localhost").Send("info#thedomain.com",
"jcarrascal#gmail.com", "testing...", "Hello, world.com"); %>
Then, I added the following to the Web.config file:
<system.net>
<mailSettings>
<smtp>
<network host="localhost"/>
</smtp>
</mailSettings>
</system.net>
In the IIS Manager I've changed the following in the properties of the "Default SMTP Virtual Server".
General: [X] Enable Logging
Access / Authentication: [X] Windows Integrated Authentication
Access / Relay Restrictions: (o) Only the list below, Granted 127.0.0.1
Delivery / Advanced: Fully qualified domain name = thedomain.com
Finally, I run the SMTPDiag.exe tool like this:
C:\>smtpdiag.exe info#thedomain.com jcarrascal#gmail.com
Searching for Exchange external DNS settings.
Computer name is THEDOMAIN.
Failed to connect to the domain controller. Error: 8007054b
Checking SOA for gmail.com.
Checking external DNS servers.
Checking internal DNS servers.
SOA serial number match: Passed.
Checking local domain records.
Checking MX records using TCP: thedomain.com.
Checking MX records using UDP: thedomain.com.
Both TCP and UDP queries succeeded. Local DNS test passed.
Checking remote domain records.
Checking MX records using TCP: gmail.com.
Checking MX records using UDP: gmail.com.
Both TCP and UDP queries succeeded. Remote DNS test passed.
Checking MX servers listed for jcarrascal#gmail.com.
Connecting to gmail-smtp-in.l.google.com [209.85.199.27] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to gmail-smtp-in.l.google.com.
Connecting to gmail-smtp-in.l.google.com [209.85.199.114] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to gmail-smtp-in.l.google.com.
Connecting to alt2.gmail-smtp-in.l.google.com [209.85.135.27] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt2.gmail-smtp-in.l.google.com.
Connecting to alt2.gmail-smtp-in.l.google.com [209.85.135.114] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt2.gmail-smtp-in.l.google.com.
Connecting to alt1.gmail-smtp-in.l.google.com [209.85.133.27] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt1.gmail-smtp-in.l.google.com.
Connecting to alt2.gmail-smtp-in.l.google.com [74.125.79.27] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt2.gmail-smtp-in.l.google.com.
Connecting to alt2.gmail-smtp-in.l.google.com [74.125.79.114] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt2.gmail-smtp-in.l.google.com.
Connecting to alt1.gmail-smtp-in.l.google.com [209.85.133.114] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt1.gmail-smtp-in.l.google.com.
Connecting to gsmtp183.google.com [64.233.183.27] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to gsmtp183.google.com.
Connecting to gsmtp147.google.com [209.85.147.27] on port 25.
Connecting to the server failed. Error: 10051
Failed to submit mail to gsmtp147.google.com.
I'm using ASP.NET 2.0, Windows 2003 Server and the IIS that comes with it.
Can you tell me what else to change to fix the problem?
Thanks
#mattlant
This is a dedicated server that's why I'm installing the SMTP manually.
EDIT: I use exchange so its a little
different, but its called a smart host
in exchange, but in plain SMTP service
config i think its called something
else. Cant remember exactly the
setting name.
Thank you for pointing me at the Smart host field. Mail is getting delivered now.
In the Default SMTP Virtual Server properties, the Delivery tab, click Advanced and fill the "Smart host" field with the address that your provider gives you. In my case (GoDaddy) it was k2smtpout.secureserver.net.
More info here: http://help.godaddy.com/article/1283
I find the best thing usually depending on how much email there is, is to just forward the mail through your ISP's SMTP server. Less headaches. Looks like that's where you are having issues, from your SMTP to external servers, not asp.net to your SMTP.
Just have your SMTP server set to send it to your ISP, or you can configure asp.net to send to it.
EDIT: I use exchange so it's a little different, but it's called a smart host in exchange, but in plain SMTP service config I think it's called something else.
I can't remember exactly the setting name.
By the looks of things your firewall isn't letting SMTP (TCP port 25) out of your network.
two really obvious questions (just in case they haven't been covered)
1. has windows firewall been disabled?
2. do you have a personal/company firewall that is preventing your mail from being sent?

Resources