Showing results for 
Search instead for 
Did you mean: 

SocketException when calling getHostedPaymentPageRequest using example code

I am seeing this error when running sample code on server A:


Attempting to connect to Authorize.NET sandbox.


Error Message: Error in transaction - System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
Unable to connect to the remote server
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at AuthorizeNet.Util.HttpUtility.PostData[TQ,TS](Environment env, TQ request) at AuthorizeNet.Api.Controllers.Bases.ApiOperationBase`2.Execute(Environment environment) at AuthorizeResponse._Default.GetTransactionID(String ApiLoginID, String ApiTransactionKey, Decimal amount) at AuthorizeResponse._Default.Page_Load(Object sender, EventArgs e)


I AM able to run the same code on Server B with NO connection error. 


Sample code used: with appropriate replacement for ApiLoginID and ApiTransactionKey. 


Confirmed using TLS 1.2 and added a new line in sample code to ensure TLS 1.2

Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls12


Any ideas?