DynamoDb SocketException: A socket operation was attempted to an unreachable network

a socket operation was attempted to an unreachable network c
a socket operation was attempted to an unreachable network idm
amazons3client profile c#
iis aws credentials
sdk credential store
.net aws s3 credentials
how to get awsprofilename
the app config web config files for the application did not contain region information

I'm trying to connect to DynamoDb locally run using docker: docker run -p 8000:8000 dwmkerr/dynamodb -sharedDb

But I keep getting the error mentioned in the title.

I can validate that DynamoDb server is running and accessible.

I can access the url http://localhost:8000/shell/

I even tried using a nodejs client https://github.com/aaronshaf/dynamodb-admin and managed to create some tables.

However, it is only dotnet code that doesn't run !

class Program
{
    static void Main(string[] args)
    {
        var clientConfig = new AmazonDynamoDBConfig()
        {
            UseHttp = true,
            LogMetrics = true,
            LogResponse = true,
            DisableLogging = false,
            ServiceURL = "http://localhost:8000"
        };

        var dynamoClient = new AmazonDynamoDBClient(clientConfig);

        //AWSSDK
        var request = new CreateTableRequest
        {
            TableName = "Todo",
            KeySchema = new List<KeySchemaElement> { new KeySchemaElement("Id", KeyType.HASH), },
            AttributeDefinitions = new List<AttributeDefinition> { new AttributeDefinition("Id", ScalarAttributeType.N), },
            ProvisionedThroughput = new ProvisionedThroughput
            {
                ReadCapacityUnits = 10,
                WriteCapacityUnits = 5,
            }
        };
        dynamoClient.CreateTableAsync(request).Wait();
    }
}

Here is the full stack trace:

Unhandled Exception: System.AggregateException: One or more errors occurred. (A socket operation was attempted to an unreachable network) ---> System.Net.Http.HttpRequestException: A socket operation was attempted to an unreachable network ---> System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable network
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at System.Net.Http.HttpClient.GetStringAsyncCore(Task`1 getTask)
   at Amazon.Runtime.Internal.Util.AsyncHelpers.<>c__DisplayClass1_1`1.<<RunSync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Amazon.Runtime.Internal.Util.AsyncHelpers.ExclusiveSynchronizationContext.BeginMessageLoop() in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Internal\Util\_mobile\AsyncHelpers.cs:line 142
   at Amazon.Runtime.Internal.Util.AsyncHelpers.RunSync[T](Func`1 task) in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Internal\Util\_mobile\AsyncHelpers.cs:line 87
   at Amazon.Util.AWSSDKUtils.DownloadStringContent(Uri uri, TimeSpan timeout, IWebProxy proxy) in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Util\AWSSDKUtils.cs:line 969
   at Amazon.Util.EC2InstanceMetadata.GetItems(String relativeOrAbsolutePath, Int32 tries, Boolean slurp) in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Util\_bcl+coreclr\EC2InstanceMetadata.cs:line 513
   at Amazon.Util.EC2InstanceMetadata.get_IAMSecurityCredentials() in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Util\_bcl+coreclr\EC2InstanceMetadata.cs:line 311
   at Amazon.Runtime.DefaultInstanceProfileAWSCredentials.FetchCredentials() in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Credentials\_bcl+coreclr\DefaultInstanceProfileAWSCredentials.cs:line 142
   at Amazon.Runtime.DefaultInstanceProfileAWSCredentials.GetCredentials() in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Credentials\_bcl+coreclr\DefaultInstanceProfileAWSCredentials.cs:line 88
   at Amazon.Runtime.DefaultInstanceProfileAWSCredentials.GetCredentialsAsync() in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Credentials\_bcl+coreclr\DefaultInstanceProfileAWSCredentials.cs:line 106
   at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext) in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\Handlers\CredentialsRetriever.cs:line 90
   at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext) in E:\JenkinsWorkspaces\v3-trebuchet-release\AWSDotNetPublic\sdk\src\Core\Amazon.Runtime\Pipeline\RetryHandler\RetryHandler.cs:line 137
   at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at test_dynamodb.Program.Main(String[] args) in G:\Test Projects\test-dynamodb\test-dynamodb\Program.cs:line 39

Surprisingly, it runs well on Mac!


If you trace down the stack a ways, you'll see that this exception isn't due to the SDK's attempt to connect to DynamoDB, but rather to the EC2 Instance Metadata URL (http://169.254.169.254). The DynamoDB client is trying to retrieve an IAM role from EC2, and when run outside of EC2, is unable to do so.

I'm seeing this exception crop up from AWSSDK.Core version 3.3.24.6 on, rather than the much more meaningful exception that used to be thrown:

Amazon.Runtime.AmazonServiceException : Failed to retrieve credentials from EC2 Instance Metadata Service.

The root cause of your issue, however, is that you haven't made AWS credentials available to the SDK. Add a default profile in AWS Explorer for Visual Studio, or create a credentials file, and you should be up and running.

EC2 Metadata Retrieval throws misleading exception on failure , A socket operation was attempted to an unreachable network the dependency on connecting to EC2 makes using the dynamodb local  The problem is a misconfigured server. A socket operation was attempted to an unreachable network 172.16.13.205:1530. The server returned its local network IP address in the 227 response to the PASV command. Your client (the FtpWebRequest) naturally cannot connect to that address and fails.


I had this problem and it took me a while to track it down.

It is caused by not having correct credentials in your AWS credentials file.

In my case I had overwritten the [default] credentials and the SDK could not authenticate properly.

Once I had fixed this it started to work.

I am using the AWSSDK.Lambda NuGet package version 3.3.102.46.

A socket operation was attempted to an unreachable network , Exception Details: System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable network 192.168.234.235:25. (A socket operation was attempted to an unreachable network) ---> System.Net.Http.HttpRequestException: A socket operation was attempted to an unreachable network ---> System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable network at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port


Instead of creating an AWS profile, you can simply specify random keys:

var client = new AmazonDynamoDBClient(
    awsAccessKeyId: "test",
    awsSecretAccessKey: "test",
    clientConfig);

This bypassed the profile check, and the access key values are not used.

windows instance fails to generate, 10 units of read capacity for Amazon DynamoDB. The error was: A socket operation was attempted to an unreachable host. Sockets.SocketException: A connection attempt failed because the connected party did not The instance "i-​aeb900c7" network interface could not be initialized properly due to  Stack Trace: [SocketException (0x2743): A socket operation was attempted to an unreachable network 192.168.234.235:25] System.Net.Sockets.Socket.DoConnect (EndPoint endPointSnapshot, SocketAddress socketAddress) +1073657.


https://social.technet.microsoft.com/Forums/en-US/, Solution: Issue was in the network. The scope had some policies applied to that stopped the operation. Localhost Endpoint to DynamoDB Local with Boto3. DynamoDb SocketException: A socket operation was attempted to an unreachable network. 0.


socket operation was attempted to an unreachable network, SocketException: A socket operation was attempted to an unreachable network 192. Socket timeout When Connecting container to external Docker Networks  We have some systems that show the A socket operation was attempted to an unreachable host message and crash the application. It starts with the following exception: System.Net.Sockets.SocketException (0x80004005): A socket operation was


Dynamodb socket timeout, Free source code and tutorials for Software developers and Architects.; Updated: 6 Nov 2015. Running the 2-iteration load test in VS 2010 now throws 52 errors: Exception SocketException 52 A socket operation was attempted to an unreachable network 66.235.126.128:80 Exception LoadTestException 1 40 Web test requests were not bound to either the correct IP address for IP switching, or the correct port number for network emulation, or both.