403 Forbidden with Java but not web browser?

You just need to set user agent header for it to work: URLConnection connection = new URL(“https://www.google.com/search?q=” + query).openConnection(); connection.setRequestProperty(“User-Agent”, “Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11”); connection.connect(); BufferedReader r = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charset.forName(“UTF-8”))); StringBuilder sb = new StringBuilder(); String line; while ((line = r.readLine()) != null) { sb.append(line); } … Read more

Why does Nginx return a 403 even though all permissions are set properly?

I experienced the same problem and it was due to SELinux. To check if SELinux is running: # getenforce To disable SELinux until next reboot: # setenforce Permissive Restart Nginx and see if the problem persists. If you would like to permanently alter the settings you can edit /etc/sysconfig/selinux If SELinux is your problem you … Read more

WAMP 403 Forbidden message on Windows 7

The access to your Apache server is forbidden from addresses other than 127.0.0.1 in httpd.conf (Apache’s config file) : <Directory “c:/wamp/www/”> Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Deny from all Allow from 127.0.0.1 </Directory> The same goes for your PHPMyAdmin access, the config file is phpmyadmin.conf : <Directory “c:/wamp/apps/phpmyadmin3.4.5/”> Options Indexes FollowSymLinks MultiViews AllowOverride … Read more

Problem HTTP error 403 in Python 3 Web Scraping

This is probably because of mod_security or some similar server security feature which blocks known spider/bot user agents (urllib uses something like python urllib/3.3.0, it’s easily detected). Try setting a known browser user agent with: from urllib.request import Request, urlopen req = Request( url=”http://www.cmegroup.com/trading/products/#sortField=oi&sortAsc=false&venues=3&page=1&cleared=1&group=1″, headers={‘User-Agent’: ‘Mozilla/5.0’} ) webpage = urlopen(req).read() This works for me. By … Read more

Nginx 403 error: directory index of [folder] is forbidden

If you have directory indexing off, and is having this problem, it’s probably because the try_files you are using has a directory option: location / { try_files $uri $uri/ /index.html index.php; } ^ that is the issue Remove it and it should work: location / { try_files $uri /index.html index.php; } Why this happens TL;DR: … Read more

Error message “Forbidden You don’t have permission to access / on this server” [closed]

Update October 2016 4 years ago, since this answer is used as a reference by many, and while I learned a lot from security perspective during these years, I feel I am responsible to clarify some important notes, and I’ve update my answer accordingly. The original answer is correct but not safe for some production … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)