When deploying a django project to AWS Elastic Beanstalk, I am able to get to all of my urlpatterns except the root pattern (i.e. what should map to sitename-staging.us-east-1.elasticbeanstalk.com). The page never loads anything and eventually chrome shows ERR_CONNECTION_TIMED_OUT. Note that I am able to get to all my other routes (i.e. sitename-staging.us-east-1.elasticbeanstalk.com/members, /admin, etc) and all the static files are on S3 and seem to be working.
urlpatterns = [
url(r'^$', TemplateView.as_view(template_name='pages/home.html'), name='home'),
url(r'^users/', include('sitename.users.urls', namespace='users')),
url(r'^accounts/', include('allauth.urls')),
url(r'^members/', include('sitename.members.urls', namespace='members')),
url(r'^contact/', include('sitename.contact.urls', namespace='contact')),
url(r'^settings/', include('sitename.sitesettings.urls', namespace='settings')),
url(r'^history/$', views.flatpage, {'url': '/history/'}, name='history'),
url(settings.ADMIN_URL, include(admin.site.urls)),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
There are no errors during deployment and the health shows ok on the dashboard. I am able to get to my root route as expected when running locally or with docker.
This isn't an issue with the template I am trying to route to as I can change the route and it will load correctly at the new route:
ex: url(r'^test$', TemplateView.as_view(template_name='pages/home.html'), name='home'),
I have tried moving the ^$ route up and down above the other named routes but that doesn't seem to work
Nothing is sticking out in the logs, but it seems as if the request never even gets to Apache from what I can understand as I am not getting back a 4xx or 5xx error and there isn't an entry that I tried to view the page in /var/log/httpd/access_log
/opt/python/log/supervisord.log:
2017-07-30 00:52:14,064 CRIT Supervisor running as root (no user in config file)
2017-07-30 00:52:14,085 INFO RPC interface 'supervisor' initialized
2017-07-30 00:52:14,085 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2017-07-30 00:52:14,085 INFO supervisord started with pid 3022
2017-07-30 00:52:15,088 INFO spawned: 'httpd' with pid 3105
2017-07-30 00:52:16,325 INFO success: httpd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
/var/log/httpd/error_log:
[Sun Jul 30 00:52:15.336938 2017] [lbmethod_heartbeat:notice] [pid 3105] AH02282: No slotmem from mod_heartmonitor
[Sun Jul 30 00:52:15.338467 2017] [mpm_prefork:notice] [pid 3105] AH00163: Apache/2.4.25 (Amazon) mod_wsgi/3.5 Python/3.4.3 configured -- resuming normal operations
[Sun Jul 30 00:52:15.338486 2017] [core:notice] [pid 3105] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
/var/log/httpd/access_log:
These four lines show up when I start the instance, it seems that they are trying to check '/' and getting a 404 but not sure. I have made sure 127.0.0.1 is in the ALLOWED HOSTS. See that there is a successful request to the /history route at the end
127.0.0.1 (-) - - [30/Jul/2017:02:06:10 +0000] "GET / HTTP/1.1" 404 4705 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [30/Jul/2017:02:06:12 +0000] "GET / HTTP/1.1" 404 4705 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [30/Jul/2017:02:06:13 +0000] "GET / HTTP/1.1" 404 4705 "-" "Python-urllib/2.7"
127.0.0.1 (-) - - [30/Jul/2017:02:06:15 +0000] "GET / HTTP/1.1" 404 4705 "-" "Python-urllib/2.7"
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36"
<my_ip_address> (-) - - [30/Jul/2017:01:43:34 +0000] "GET /a HTTP/1.1" 200 5871 "http://sitename-staging.us-east-1.elasticbeanstalk.com/history/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36"
/var/log/eb-activity.log
This looks odd but the are not any other errors and the other routes are working
[2017-07-30T02:06:16.844Z] INFO [25864] - [Configuration update app-ee500-170729_204230@6/ConfigDeployStage1/ConfigDeployEnactHook/01flip.py] : Completed activity. Result:
httpd: stopped
httpd: started
httpd RUNNING pid 25973, uptime 0:00:03
2017-07-30 02:06:16,750 INFO Apache is running, but root page is not responding in 3 seconds.
Additional Project Information:
- project structure similar to what cookiecutter-django produces
- doesn't have this problem running locally or on docker (gunicorn/nginx)
- static files on s3
- Database on RDS and migrated successfully
- Python 3.4
- Following this tutorial to convert my project elastic beanstalk
- ALLOWED_HOSTS contains the elastic beanstalk url, EC2 Public IP, localhost, 127.0.0.1