# Sending a POST request using httplib results in error only when run from gateway event script

**URL:** <https://forum.inductiveautomation.com/t/sending-a-post-request-using-httplib-results-in-error-only-when-run-from-gateway-event-script/45280>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [April 5, 2021, 8:08pm UTC](https://forum.inductiveautomation.com/t/sending-a-post-request-using-httplib-results-in-error-only-when-run-from-gateway-event-script/45280 "2021-04-05T20:08:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pandreoli](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@pandreoli](https://forum.inductiveautomation.com/u/pandreoli)\
**Post date:** [April 5, 2021, 8:08pm UTC](https://forum.inductiveautomation.com/t/sending-a-post-request-using-httplib-results-in-error-only-when-run-from-gateway-event-script/45280/1 "2021-04-05T20:08:15Z")

</div>

Im working with an Ignition server that was just set up by another org, so I dont have all the details regarding how the gateway or server is set up. The code below runs flawlessly from the script console, but results in the following error when run from a gateway event script:

`[Errno 8] nodename nor servname provided, or not known`

```auto
	import httplib
	from base64 import b64encode

	url_path = "example/url/path/"
    BASE_URL = "example.url.com"
	conn = httplib.HTTPSConnection(BASE_URL)
	payload = "<xml>"
	headers = {
		'Authorization': auth_header,
		'Content-Type': 'application/xml'
	}
    # Error occurs on the below line v
	conn.request("POST", url_path, body=payload, headers=headers)
    res = conn.getresponse()

```

I looked up the error and saw responses saying that the /etc/host file needs to be modified? I dont see why this would apply. Any ideas?

The full stack trace can be found below. `send_req` is the function which contains the above code.

> com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 5,  
> in File "", line 216, in send\_req\_power\_data  
> File "", line 155, in send\_req  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\httplib.py", line 1042, in request self.\_send\_request(method, url, body, headers)  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\httplib.py", line 1082, in \_send\_request self.endheaders(body)  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\httplib.py", line 1038, in endheaders self.\_send\_output(message\_body)  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\httplib.py", line 882, in \_send\_output self.send(msg)  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\httplib.py", line 844, in send self.connect()  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\httplib.py", line 1255, in connect HTTPConnection.connect(self)  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\httplib.py", line 820, in connect self.sock = self.\_create\_connection((self.host,self.port),  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\_socket.py", line 1556, in create\_connection for res in getaddrinfo(host, port, 0, SOCK\_STREAM):  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\_socket.py", line 382, in handle\_exception return method\_or\_function(\*args, \*\*kwargs)  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\_socket.py", line 382, in handle\_exception return method\_or\_function(\*args, \*\*kwargs)  
> File "C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\_socket.py", line 1770, in getaddrinfo raise gaierror(errno.ENOEXEC, 'nodename nor servname provided, or not known') \_socket.gaierror: [Errno 8] nodename nor servname provided, or not known

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [April 5, 2021, 10:53pm UTC](https://forum.inductiveautomation.com/t/sending-a-post-request-using-httplib-results-in-error-only-when-run-from-gateway-event-script/45280/2 "2021-04-05T22:53:41Z")

</div>

Running from the Script Console of the Designer is going to be using DNS lookups from your computer. Running in the gateway scope is going to be dependent on the DNS configuration of the computer running the gateway. So if DNS is not configured (or appropriate entries in the `C:\Windows\system32\drivers\etc\hosts` file (in this case on Windows) it may not be able to resolve the target name appropriately.
