An attempt was made to access a socket in a way forbidden by its access permissions
Asked Answered
K

7

13

I just downloaded C# SDK and ASP.NET MVC sample, modified it to work with 4.2.1. (web config facebookSettings parameters etc.), created my Facebook application and tried to run it. Click to facebook login button - ok, entering credentials into facebook popup - ok, allowing access for my application - ok, and then I get this error:

System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 66.220.146.47:443

var app = new FacebookApp();
if (app.Session == null)
{
   // The user isnt logged in to Facebook
   // send them to the home page
   return RedirectToAction("Index");
}

// Get the user info from the Graph API
dynamic me = app.Api("/me"); // EXCEPTION THROWN HERE
ViewData["FirstName"] = me.first_name;
ViewData["LastName"] = me.last_name;

The app object is OK I think (containing settings params, session object with access token and my facebook userid, etc.)

I am using local development address http://myappdev.local (set to 127.0.0.1 in hosts file). The same address is set in my facebook app settings, also domain myappdev.local - Can this be the problem? I have seen examples using localhost:1234 in some tutorials.

Kettie answered 25/1, 2011 at 22:36 Comment(0)
K
20

Solved... my bad - my firewall was "silently" blocking ISS worker process from connecting on port 443... I hope that at least I save somebody from the same mistake :)

Kettie answered 2/2, 2011 at 15:45 Comment(1)
My issue was also McAffee Anti-Virus blocking SMTP connections as in the comments in Franklin_Skipdiddle's answer below. (I upvoted this answer since it is basically the same as Franklin's but earlier.)Walton
D
21

If you're getting the same error in Windows 8 development, it could be that you haven't enabled access over Private Networks in your Package.appxmanifest file:

Highlighting the Private Networks (Client & Server) option

Dusty answered 17/12, 2013 at 0:2 Comment(1)
Thank you, thank you! This did not solve my problem entirely, but got me at least a step closer.Tindle
K
20

Solved... my bad - my firewall was "silently" blocking ISS worker process from connecting on port 443... I hope that at least I save somebody from the same mistake :)

Kettie answered 2/2, 2011 at 15:45 Comment(1)
My issue was also McAffee Anti-Virus blocking SMTP connections as in the comments in Franklin_Skipdiddle's answer below. (I upvoted this answer since it is basically the same as Franklin's but earlier.)Walton
E
8

My resolution was similar yet different.

The problem was on my end as well. I was using an smtp client to send mail, though. I run PeerBlock, and it blocks suspicious IPs. I saw it was blocking one of the IPs I was sending to before it left my network. A simple rule exception and the problem was solved.

TL;DR Firewalls and other internet security filtering tools should all be checked to make sure this problem isn't caused on your end.

Eblis answered 2/9, 2013 at 18:22 Comment(2)
Yup, McAffee anti-virus blocking it my case.I checked the logs and noticed the requests to the SMTP server being blocked. By temporarily disabling the Access Protection emails can be sent.Earpiercing
People are saying this could a firewall/Branded security software, however if this is on a server and the same error message is being shown on many devices - this could mean that it isnt a firewall setting? Correct?Illeetvilaine
C
6

I've been running into a similar issue when I tried to run a simple http web application listening on port 80 written in Go (golang) on Windows 10 Home.

After doing some research I found out that for some reasons the "World Wide Web Publishing Service" (W3SVC) was running. Stopping and disabling the service solved my issue.

I never used this service. I guess a Visual Studio Community 2013 installation in the past installed and enabled this service. When I encountered the problem for the first time I thought it's a privilege issue as it's the case on Linux systems where applications listening on ports < 1023 must be run with root privileges. But in Windows 1023 this is not the case.

After all, finding this trivial issue costed me about 2 hours, that's why I post this answer to this rather old thread.

Basically this is a summary of what I did:

1) Google for the error message (as fully contained in the question of this thread).
- To many issues not related to my specific issues have been returned.
- I didn't find a concrete answer that solved my problem.
- However, I found hints for further analysis.

2) The first hint was using netstat.

netstat -o -n -a | findstr 0.0.0.0:80
netstat -o -n -a | findstr 127.0.0.1:80

It turned out that the process with Id 4 was listening on port 80.

3) Lookup Process #4 on the Details tab in the Taskmanager.

This showed that System (NT Kernel & System) is involved.

4) Trying to access port 80 on localhost using PUttY with Telnet to port 80.
(make sure to set **Closing on exit* to never)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Verb</h2>
<hr><p>HTTP Error 400. The request verb is invalid.</p>
</BODY></HTML>
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Thu, 05 Oct 2017 13:13:29 GMT
Connection: close
Content-Length: 326

5) The information collected so far didn't provide a concrete hint but allowed me to do more specific searches on Google. Now the information returned from Google indicated that most likely some kind of system services listening on port 80 might be the source of the issue.

6) Now it was easy to look for such running services in the service manager. The first one I found that could likely be the source of the issue (as it contained WWW in its name) was "WWW-Publishingdienst" (on my computer in German) which stands for "World Wide Web Publishing Service" on systems with English language settings. I stopped the service and - Voila! It was the cause of the issue.

Cockade answered 5/10, 2017 at 14:48 Comment(0)
S
2

Not sure what all this was, but ipconfig /release && ipconfig /renew seemed to work for me.

Salto answered 8/8, 2020 at 14:52 Comment(1)
Also, this solved for me. I was trying to start ngrokPortrait
M
1

faced a similar problem, I checked everything that might cause the error, this includes the right port to use, firewall settings even the operating system of the server compatibility issues, only to find out that the anti-virus is the one causing it,

Make sure to disable the feature of your anti-virus that is blocking the socket connection, or add to exemption the specific .exe or program you want not to be blcocked.

Mine uses McCafee and I uncheck the feature in it that blocks socket connection for sending mails and it worked.

Migratory answered 27/5, 2015 at 5:28 Comment(0)
A
1

I run a MySQL DB locally and I had a similar problem. I did all the steps shown in posts related to the same issue:

  • Disabled firewall
  • Disabled antivirus
  • Reset TCP/IP stack
  • Restarted computer
  • Verified connection string

None of these worked. I found out that the issue for me was my VPN (Astrill). For some reason it was causing these localhost connections to fail. Disconnecting from VPN fixed my problem.

Anthropomorphous answered 1/2, 2017 at 8:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.