Title: Connection failed
Last modified: January 12, 2019

---

# Connection failed

 *  Resolved [flotschie](https://wordpress.org/support/users/flotschie/)
 * (@flotschie)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/connection-failed-3/)
 * I installed JWT according to the instruction and tested the /wp-json/jwt-auth/
   v1/token restpoint via POSTMAN. But I get this response here:
 * Connection failed: php_network_getaddresses: getaddrinfo failed: Name or service
   not known
 * Any hint?
 * EDIT: /wp-json/jwt-auth/v1/token/validate works!
 * EDIT2: Maybe something was messed up when i implemented an internal call to that
   restpoint? Here is how I do this call:
 *     ```
       	$request = new WP_REST_Request( 'POST', '/jwt-auth/v1/token' );
       	$request->set_header("Content-Type","application/json");	
       	$request->set_body('{"username": "'.$username.'",	"password": "'.$password.'"}');	
       	$response = rest_do_request( $request );
       	$server = rest_get_server();
       	$data = $server->response_to_data( $response, false );	
       	$response = $data;
       ```
   
 * This call works by the way! It is just not reachable from the outside.
 * EDIT3: Seems to have to do with the filter. When I remove the filter it works.
   Check the code with deactivated filter:
 *     ```
       	function extend_token( $data, $user ) {
   
       	  $isProvider = get_user_meta($user->ID, "isProvider", true); 
   
       	  if($isProvider == true)
       	  {
       		$data['isProvider'] = 'true';
       		$profileData = get_profile_data_by_userId($user->ID);
       		$data = array_merge($data, $profileData); 
       		$unitData = get_unit_data_by_userId($user->ID);
       		$data = array_merge($data, $unitData); 
       		$offerData = get_offer_data_by_userId($user->ID);
       		$data = array_merge($data, $offerData); 	
       		$eventData = get_event_data_by_userId($user->ID);
       		$data = array_merge($data, $eventData); 		
       	  }  
       		return $data;  
       	}
       	//add_filter( 'jwt_auth_token_before_dispatch', 'extend_token', 10, 2 );
       ```
   
    -  This topic was modified 7 years, 4 months ago by [flotschie](https://wordpress.org/support/users/flotschie/).
    -  This topic was modified 7 years, 4 months ago by [flotschie](https://wordpress.org/support/users/flotschie/).
    -  This topic was modified 7 years, 4 months ago by [flotschie](https://wordpress.org/support/users/flotschie/).
    -  This topic was modified 7 years, 4 months ago by [flotschie](https://wordpress.org/support/users/flotschie/).

Viewing 1 replies (of 1 total)

 *  Thread Starter [flotschie](https://wordpress.org/support/users/flotschie/)
 * (@flotschie)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/connection-failed-3/#post-11083847)
 * I found the issue, the extend_token function called other sub functions which
   contained database connections with invalid parameters.

Viewing 1 replies (of 1 total)

The topic ‘Connection failed’ is closed to new replies.

 * ![](https://ps.w.org/jwt-authentication-for-wp-rest-api/assets/icon-256x256.jpg?
   rev=3372068)
 * [JWT Authentication for WP REST API](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/)
 * [Active Topics](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jwt-authentication-for-wp-rest-api/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [flotschie](https://wordpress.org/support/users/flotschie/)
 * Last activity: [7 years, 4 months ago](https://wordpress.org/support/topic/connection-failed-3/#post-11083847)
 * Status: resolved