Django Raven test error - 403 Forbidden

Hi,

I’m trying to start up a brand new Sentry on-premise instance. Doing it with docker image is straightforward, and I have full Sentry instance running in couple minutes. Using web interface runs without any problems. Great!

…until I want to send something to Sentry from django with raven.

Running raven test returns HTTP error 403 Forbidden on url http://sentry/api/2/store/.

Here’s full error log:

$ docker-compose run --rm django raven test
Client configuration:
  base_url       : http://sentry
  project        : 2
  public_key     : af08418afb1d4e999cc0cf40bbac44ed
  secret_key     : 24c21d9bc3fd4b7199ecbd3a258dd14f

Sending a test message... Event ID was '397c5c7132f9440486d856e2cc70ccf1'
[2017-01-20 13:04:08,990] [ERROR  ] [sentry.errors] Sentry responded with an error: HTTP Error 403: Forbidden (url: http://sentry/api/2/store/)
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/raven/transport/threaded.py", line 174, in send_sync
    super(ThreadedHTTPTransport, self).send(data, headers)
  File "/usr/local/lib/python2.7/dist-packages/raven/transport/http.py", line 47, in send
    ca_certs=self.ca_certs,
  File "/usr/local/lib/python2.7/dist-packages/raven/utils/http.py", line 66, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden
Sentry responded with an error: HTTP Error 403: Forbidden (url: http://sentry/api/2/store/)
[2017-01-20 13:04:08,992] [ERROR  ] [sentry.errors.uncaught] [u'This is a test message generated using ``raven test``']
[u'This is a test message generated using ``raven test``']

Here’s my setup:

#docker-compose.yml
version: '2'

services:
  sentry:
    image: sentry
    container_name: sentry
    restart: always
    env_file:
      - local.env
    ports:
      - "9000:9000"
    depends_on:
      - db
      - redis

  cron:
    image: sentry
    container_name: sentry_cron
    command: run cron
    restart: always
    env_file:
      - local.env

  worker:
    image: sentry
    container_name: sentry_worker
    command: run worker
    restart: always
    env_file:
      - local.env

  redis:
    image: redis
    container_name: sentry_redis
    restart: always

  db:
    image: postgres
    container_name: sentry_db
    restart: always
# local.env
SENTRY_SECRET_KEY=&am60&z+!(u^3d*!f-f1pw603yj-rv4g2(gm4^u1c&2bfx841u

SENTRY_POSTGRES_HOST=sentry_db
SENTRY_REDIS_HOST=sentry_redis
# django settings.py
...
# Raven
RAVEN_CONFIG = {
    'dsn': 'http://af08418afb1d4e999cc0cf40bbac44ed:24c21d9bc3fd4b7199ecbd3a258dd14f@sentry/2',
}
...

And given DSN from web interface is http://af08418afb1d4e999cc0cf40bbac44ed:24c21d9bc3fd4b7199ecbd3a258dd14f@sentry/2.

Sentry version: 8.12.0
Raven version 5.32.0 (both server and client)

I tried everything but I can’t make raven work. I can’t find anything useful in web either.

Any ideas?

@matt – any suggestions?

I took 4th try to solve my problem, and after hours I figured it out. It’s finally working now.

My problem was caused by on-premise specific proxy settings. Error 403 was not returning by sentry, as simple log message suggested, but was returning by proxy server. Raven request was not even hitting sentry logs. Local manual request checking (curl/wget when curl is more verbose) confusingly worked fine because remote servers running raven and sentry was in different network than my local dev pc, on-premise specific. Request checking from remote servers was failing. Remote machines was not even able to talk with each other by domain/ip, when cross-machine connection based on Docker Swarm Mode worked fine.

Adding domain in no_proxy environment variable fixed the problem.

Anyways:
Maybe little reminding about proxies in on-premise installations would save some time for next folks?

It’d help if I had literally any idea what any of your problem was. :slight_smile: What you have setup sounds very odd and unusual to me nor have I used any of those tools. The problem sounds more related to your setup, and not a problem with Sentry itself, so not sure how we’d improve documentation for that.

Hey, Did you tried to access the same page from some other pc or laptop? If the problem persists then it may be beacuse the webiste owner has restricted you from access that page. Well there’s a simple soln. to it…Install gom vpn extension from here.it will let you bypass this restriction in seconds.