diff --git a/oslo/messaging/transport.py b/oslo/messaging/transport.py
index 8fdfca1f3..62a5480e3 100644
--- a/oslo/messaging/transport.py
+++ b/oslo/messaging/transport.py
@@ -386,7 +386,9 @@ class TransportURL(object):
                 if ':' in username:
                     username, password = username.split(':', 1)
 
-            if hostname[0] == '[':
+            if not hostname:
+                hostname = None
+            elif hostname.startswith('['):
                 # Find the closing ']' and extract the hostname
                 host_end = hostname.find(']')
                 if host_end < 0:
diff --git a/tests/test_urls.py b/tests/test_urls.py
index a83ac400a..84f5a177a 100644
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -78,6 +78,13 @@ class TestParseURL(test_utils.BaseTestCase):
                               dict(host='host', port=1234,
                                    username='u', password='p'),
                           ]))),
+        ('creds_no_host',
+         dict(url='foo://u:p@/bar',
+              expect=dict(transport='foo',
+                          virtual_host='bar',
+                          hosts=[
+                              dict(username='u', password='p'),
+                          ]))),
         ('multi_host',
          dict(url='foo://u:p@host1:1234,host2:4321/bar',
               expect=dict(transport='foo',