urllib3.exceptions.LocationValueError: No host specified.
See original GitHub issueHi there.
First of all many thanks to all people involved in this project.
I’m facing an issue with version 1.25.2 of this library, which is not happening with version 1.24.1.
Steps to reproduce:
- Create “requirements.txt” with below content:
selenium
urllib3==1.24.1
#urllib3==1.25.2
- Create “Dockerfile” with below content:
FROM python:3-stretch
ADD requirements.txt .
RUN pip install -r requirements.txt
COPY test.py /test.py
- Create “test.py” with below content:
#!/usr/bin/python
from selenium import webdriver
host = 'selenium'
port = '4444'
url = host + ':' + port + '/wd/hub'
desired_capabilities = {
'browserName': 'firefox',
'javascriptEnabled': True,
}
driver = webdriver.Remote(command_executor = url, desired_capabilities =
desired_capabilities)
print('Success')
driver.quit()
- Create “docker-compose.yaml” with below content:
services:
urllib3:
container_name: urllib3
build:
context: .
stdin_open: true
tty: true
selenium:
container_name: selenium
image: selenium/standalone-firefox
# Mandatory, to avoid "Message: Failed to decode response from marionette" error
shm_size: 128m
- Bring up the environment
docker-compose up -d --build
- Test it:
docker exec -ti urllib3 python /test.py
Expected output:
Success
- Now edit “requirements.txt”
vim requirements.txt
And specify version 1.25.2 of urllib3:
selenium
#urllib3==1.24.1
urllib3==1.25.2
- Bring down the environment
docker-compose down
- Bring up the environment
docker-compose up -d --build
- Test it:
docker exec -ti urllib3 python /test.py
Expected output:
Traceback (most recent call last):
File "test.py", line 15, in <module>
desired_capabilities)
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 402, in _request
resp = http.request(method, url, body=body, headers=headers)
File "/usr/local/lib/python3.7/site-packages/urllib3/request.py", line 72, in request
**urlopen_kw)
File "/usr/local/lib/python3.7/site-packages/urllib3/request.py", line 150, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/usr/local/lib/python3.7/site-packages/urllib3/poolmanager.py", line 315, in urlopen
conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
File "/usr/local/lib/python3.7/site-packages/urllib3/poolmanager.py", line 222, in connection_from_host
raise LocationValueError("No host specified.")
urllib3.exceptions.LocationValueError: No host specified.
- (Optional) Cleanup
docker-compose down
docker rmi localhost/urllib3:latest
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Python Error:No host specified - Stack Overflow
I just wrote a simple python demo,while met a confusing problem. import requests print(requests.get('http://www.sina.com.cn/ ...
Read more >Urllib3 Python3, Getting Error No host specified, but the url ...
I am trying to write images to database from excel sheet. I have this function to download images. def downloadImage(url, Name): try: http ......
Read more >Exceptions - urllib3 1.26.13 documentation
Raised when get_host or similar fails to parse the URL input. exception urllib3.exceptions.LocationValueError#. Bases: ValueError ...
Read more >connectionpool.py - Google Git
from .exceptions import ( ... raise LocationValueError("No host specified.") ... Additional parameters are used to create fresh :class:`urllib3.connection.
Read more >urllib3 [python2-library] - Occam :: Details
urllib3 is a powerful, user-friendly HTTP client for Python. ... Requesting an empty host will raise urllib3.exceptions.LocationValueError . (Issue #417).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

(Also I suspect you can fix your issue by adding
http://to the beginning of your URL)When i change http://selenium:4444/wd/hub on http://X.X.X.X:4444/wd/hub it working